Skip to content

Commit 4e470cb

Browse files
committed
osd/scrub: count scrub I/O
Implement I/O counting in the PGBackend::be_scan_list() and relevant functions it calls. Signed-off-by: Ronen Friedman <[email protected]>
1 parent 7e91398 commit 4e470cb

File tree

10 files changed

+44
-12
lines changed

10 files changed

+44
-12
lines changed

src/osd/ECBackend.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1767,6 +1767,7 @@ int ECBackend::objects_get_attrs(
17671767
}
17681768

17691769
int ECBackend::be_deep_scrub(
1770+
const Scrub::ScrubCounterSet& io_counters,
17701771
const hobject_t &poid,
17711772
ScrubMap &map,
17721773
ScrubMapBuilder &pos,
@@ -1793,6 +1794,8 @@ int ECBackend::be_deep_scrub(
17931794
if (stride % sinfo.get_chunk_size())
17941795
stride += sinfo.get_chunk_size() - (stride % sinfo.get_chunk_size());
17951796

1797+
auto& perf_logger = *(get_parent()->get_logger());
1798+
perf_logger.inc(io_counters.read_cnt);
17961799
bufferlist bl;
17971800
r = switcher->store->read(
17981801
switcher->ch,
@@ -1817,6 +1820,7 @@ int ECBackend::be_deep_scrub(
18171820
if (r > 0) {
18181821
pos.data_hash << bl;
18191822
}
1823+
perf_logger.inc(io_counters.read_bytes, r);
18201824
pos.data_pos += r;
18211825
if (r == (int)stride) {
18221826
return -EINPROGRESS;

src/osd/ECBackend.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,7 @@ class ECBackend : public ECCommon {
507507
bool auto_repair_supported() const { return true; }
508508

509509
int be_deep_scrub(
510+
const Scrub::ScrubCounterSet& io_counters,
510511
const hobject_t &poid,
511512
ScrubMap &map,
512513
ScrubMapBuilder &pos,

src/osd/ECBackendL.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1727,6 +1727,7 @@ int ECBackendL::objects_get_attrs(
17271727
}
17281728

17291729
int ECBackendL::be_deep_scrub(
1730+
const Scrub::ScrubCounterSet& io_counters,
17301731
const hobject_t &poid,
17311732
ScrubMap &map,
17321733
ScrubMapBuilder &pos,
@@ -1754,6 +1755,8 @@ int ECBackendL::be_deep_scrub(
17541755
if (stride % sinfo.get_chunk_size())
17551756
stride += sinfo.get_chunk_size() - (stride % sinfo.get_chunk_size());
17561757

1758+
auto& perf_logger = *(get_parent()->get_logger());
1759+
perf_logger.inc(io_counters.read_cnt);
17571760
bufferlist bl;
17581761
r = switcher->store->read(
17591762
switcher->ch,
@@ -1778,6 +1781,7 @@ int ECBackendL::be_deep_scrub(
17781781
if (r > 0) {
17791782
pos.data_hash << bl;
17801783
}
1784+
perf_logger.inc(io_counters.read_bytes, r);
17811785
pos.data_pos += r;
17821786
if (r == (int)stride) {
17831787
return -EINPROGRESS;

src/osd/ECBackendL.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,7 @@ END_IGNORE_DEPRECATED
436436
bool auto_repair_supported() const { return true; }
437437

438438
int be_deep_scrub(
439+
const Scrub::ScrubCounterSet& io_counters,
439440
const hobject_t &poid,
440441
ScrubMap &map,
441442
ScrubMapBuilder &pos,

src/osd/ECSwitch.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -301,13 +301,15 @@ class ECSwitch : public PGBackend
301301
return legacy.be_get_ondisk_size(logical_size);
302302
}
303303

304-
int be_deep_scrub(const hobject_t &oid, ScrubMap &map, ScrubMapBuilder &pos
305-
, ScrubMap::object &o)
304+
int be_deep_scrub(
305+
const Scrub::ScrubCounterSet &io_counters,
306+
const hobject_t &oid, ScrubMap &map, ScrubMapBuilder &pos,
307+
ScrubMap::object &o) override
306308
{
307309
if (is_optimized()) {
308-
return optimized.be_deep_scrub(oid, map, pos, o);
310+
return optimized.be_deep_scrub(io_counters, oid, map, pos, o);
309311
}
310-
return legacy.be_deep_scrub(oid, map, pos, o);
312+
return legacy.be_deep_scrub(io_counters, oid, map, pos, o);
311313
}
312314

313315
unsigned get_ec_data_chunk_count() const override

src/osd/PGBackend.cc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -774,17 +774,20 @@ PGBackend *PGBackend::build_pg_backend(
774774
}
775775

776776
int PGBackend::be_scan_list(
777+
const Scrub::ScrubCounterSet& io_counters,
777778
ScrubMap &map,
778779
ScrubMapBuilder &pos)
779780
{
780781
dout(10) << __func__ << " " << pos << dendl;
781782
ceph_assert(!pos.done());
782783
ceph_assert(pos.pos < pos.ls.size());
783784
hobject_t& poid = pos.ls[pos.pos];
785+
auto& perf_logger = *(get_parent()->get_logger());
784786

785787
int r = 0;
786788
ScrubMap::object &o = map.objects[poid];
787789
if (!pos.metadata_done) {
790+
perf_logger.inc(io_counters.stats_cnt);
788791
struct stat st;
789792
r = store->stat(
790793
ch,
@@ -794,6 +797,7 @@ int PGBackend::be_scan_list(
794797
true);
795798

796799
if (r == 0) {
800+
perf_logger.inc(io_counters.getattr_cnt);
797801
o.size = st.st_size;
798802
ceph_assert(!o.negative);
799803
r = store->getattrs(
@@ -828,7 +832,7 @@ int PGBackend::be_scan_list(
828832
}
829833

830834
if (pos.deep) {
831-
r = be_deep_scrub(poid, map, pos, o);
835+
r = be_deep_scrub(io_counters, poid, map, pos, o);
832836
if (r == -EINPROGRESS) {
833837
return -EINPROGRESS;
834838
} else if (r != 0) {

src/osd/PGBackend.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include "common/WorkQueue.h"
2828
#include "include/Context.h"
2929
#include "os/ObjectStore.h"
30+
#include "osd/scrubber_common.h"
3031
#include "common/LogClient.h"
3132
#include <string>
3233
#include "PGTransaction.h"
@@ -599,14 +600,17 @@ typedef std::shared_ptr<const OSDMap> OSDMapRef;
599600
Context *on_complete, bool fast_read = false) = 0;
600601

601602
virtual bool auto_repair_supported() const = 0;
603+
602604
int be_scan_list(
605+
const Scrub::ScrubCounterSet& io_counters,
603606
ScrubMap &map,
604607
ScrubMapBuilder &pos);
605608

606609
virtual uint64_t be_get_ondisk_size(uint64_t logical_size,
607610
shard_id_t shard_id) const = 0;
608611

609612
virtual int be_deep_scrub(
613+
[[maybe_unused]] const Scrub::ScrubCounterSet& io_counters,
610614
const hobject_t &oid,
611615
ScrubMap &map,
612616
ScrubMapBuilder &pos,

src/osd/ReplicatedBackend.cc

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,7 @@ void ReplicatedBackend::submit_transaction(
624624
pg_committed_to,
625625
true,
626626
op_t);
627-
627+
628628
op_t.register_on_commit(
629629
parent->bless_context(
630630
new C_OSD_OnOpCommit(this, &op)));
@@ -745,16 +745,17 @@ static uint32_t crc32_netstring(const uint32_t orig_crc, std::string_view data)
745745
}
746746

747747
int ReplicatedBackend::be_deep_scrub(
748+
const Scrub::ScrubCounterSet& io_counters,
748749
const hobject_t &poid,
749750
ScrubMap &map,
750751
ScrubMapBuilder &pos,
751752
ScrubMap::object &o)
752753
{
753754
dout(10) << __func__ << " " << poid << " pos " << pos << dendl;
754-
int r;
755-
uint32_t fadvise_flags = CEPH_OSD_OP_FLAG_FADVISE_SEQUENTIAL |
756-
CEPH_OSD_OP_FLAG_FADVISE_DONTNEED |
757-
CEPH_OSD_OP_FLAG_BYPASS_CLEAN_CACHE;
755+
auto& perf_logger = *(get_parent()->get_logger());
756+
const uint32_t fadvise_flags = CEPH_OSD_OP_FLAG_FADVISE_SEQUENTIAL |
757+
CEPH_OSD_OP_FLAG_FADVISE_DONTNEED |
758+
CEPH_OSD_OP_FLAG_BYPASS_CLEAN_CACHE;
758759

759760
utime_t sleeptime;
760761
sleeptime.set_from_double(cct->_conf->osd_debug_deep_scrub_sleep);
@@ -763,6 +764,7 @@ int ReplicatedBackend::be_deep_scrub(
763764
sleeptime.sleep();
764765
}
765766

767+
int r{0};
766768
ceph_assert(poid == pos.ls[pos.pos]);
767769
if (!pos.data_done()) {
768770
if (pos.data_pos == 0) {
@@ -771,6 +773,7 @@ int ReplicatedBackend::be_deep_scrub(
771773

772774
const uint64_t stride = cct->_conf->osd_deep_scrub_stride;
773775

776+
perf_logger.inc(io_counters.read_cnt);
774777
bufferlist bl;
775778
r = store->read(
776779
ch,
@@ -788,6 +791,7 @@ int ReplicatedBackend::be_deep_scrub(
788791
if (r > 0) {
789792
pos.data_hash << bl;
790793
}
794+
perf_logger.inc(io_counters.read_bytes, r);
791795
pos.data_pos += r;
792796
if (static_cast<uint64_t>(r) == stride) {
793797
dout(20) << __func__ << " " << poid << " more data, digest so far 0x"
@@ -806,6 +810,7 @@ int ReplicatedBackend::be_deep_scrub(
806810
if (pos.omap_pos.empty()) {
807811
pos.omap_hash = -1;
808812

813+
perf_logger.inc(io_counters.omapgetheader_cnt);
809814
bufferlist hdrbl;
810815
r = store->omap_get_header(
811816
ch,
@@ -822,10 +827,13 @@ int ReplicatedBackend::be_deep_scrub(
822827
bool encoded = false;
823828
dout(25) << "CRC header " << cleanbin(hdrbl, encoded, true) << dendl;
824829
pos.omap_hash = hdrbl.crc32c(pos.omap_hash);
830+
perf_logger.inc(io_counters.omapgetheader_bytes, hdrbl.length());
825831
}
826832
}
827833

828834
// omap
835+
836+
perf_logger.inc(io_counters.omapget_cnt);
829837
using omap_iter_seek_t = ObjectStore::omap_iter_seek_t;
830838
auto result = store->omap_iterate(
831839
ch,
@@ -859,6 +867,9 @@ int ReplicatedBackend::be_deep_scrub(
859867
return -EINPROGRESS;
860868
}
861869

870+
// we have the full omap now. Finalize the perf counting
871+
perf_logger.inc(io_counters.omapget_bytes, pos.omap_bytes);
872+
862873
if (pos.omap_keys > cct->_conf->
863874
osd_deep_scrub_large_omap_object_key_threshold ||
864875
pos.omap_bytes > cct->_conf->

src/osd/ReplicatedBackend.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,7 @@ class ReplicatedBackend : public PGBackend {
457457

458458

459459
int be_deep_scrub(
460+
const Scrub::ScrubCounterSet& io_counters,
460461
const hobject_t &poid,
461462
ScrubMap &map,
462463
ScrubMapBuilder &pos,

src/osd/scrubber/pg_scrubber.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1404,8 +1404,8 @@ int PgScrubber::build_scrub_map_chunk(ScrubMap& map,
14041404

14051405
// scan objects
14061406
while (!pos.done()) {
1407-
1408-
int r = m_pg->get_pgbackend()->be_scan_list(map, pos);
1407+
int r =
1408+
m_pg->get_pgbackend()->be_scan_list(get_unlabeled_counters(), map, pos);
14091409
dout(30) << __func__ << " BE returned " << r << dendl;
14101410
if (r == -EINPROGRESS) {
14111411
dout(20) << __func__ << " in progress" << dendl;

0 commit comments

Comments
 (0)