From 8f0514bf59bad486df63d078b57df636eb969bc5 Mon Sep 17 00:00:00 2001 From: David Zafman Date: Fri, 20 Apr 2018 12:19:56 -0700 Subject: [PATCH] osd: process _scan_snaps() with all snapshots with head Fixes: http://tracker.ceph.com/issues/22881 Signed-off-by: David Zafman --- src/osd/PG.cc | 34 ++++++++++++++++------------------ src/osd/PG.h | 20 ++++++++++++++++++++ 2 files changed, 36 insertions(+), 18 deletions(-) diff --git a/src/osd/PG.cc b/src/osd/PG.cc index c4805e03ae8d3..8c4f492b5d2d8 100644 --- a/src/osd/PG.cc +++ b/src/osd/PG.cc @@ -4367,12 +4367,19 @@ void PG::_scan_snaps(ScrubMap &smap) { hobject_t head; SnapSet snapset; + + // Test qa/standalone/scrub/osd-scrub-snaps.sh uses this message to verify + // caller using clean_meta_map(), and it works properly. + dout(20) << __func__ << " start" << dendl; + for (map::reverse_iterator i = smap.objects.rbegin(); i != smap.objects.rend(); ++i) { const hobject_t &hoid = i->first; ScrubMap::object &o = i->second; + dout(20) << __func__ << " " << hoid << dendl; + assert(!hoid.is_snapdir()); if (hoid.is_head()) { // parse the SnapSet @@ -4556,8 +4563,13 @@ int PG::build_scrub_map_chunk( // finish dout(20) << __func__ << " finishing" << dendl; assert(pos.done()); - _scan_snaps(map); _repair_oinfo_oid(map); + if (!is_primary()) { + ScrubMap for_meta_scrub; + scrubber.cleaned_meta_map.insert(map); + scrubber.clean_meta_map(for_meta_scrub); + _scan_snaps(for_meta_scrub); + } dout(20) << __func__ << " done, got " << map.objects.size() << " items" << dendl; @@ -5325,26 +5337,12 @@ void PG::scrub_compare_maps() } ScrubMap for_meta_scrub; - if (scrubber.end.is_max() || - scrubber.cleaned_meta_map.objects.empty()) { - scrubber.cleaned_meta_map.swap(for_meta_scrub); - } else { - auto iter = scrubber.cleaned_meta_map.objects.end(); - --iter; // not empty, see if clause - auto begin = scrubber.cleaned_meta_map.objects.begin(); - while (iter != begin) { - auto next = iter--; - if (next->first.get_head() != iter->first.get_head()) { - ++iter; - break; - } - } - for_meta_scrub.objects.insert(begin, iter); - scrubber.cleaned_meta_map.objects.erase(begin, iter); - } + scrubber.clean_meta_map(for_meta_scrub); // ok, do the pg-type specific scrubbing scrub_snapshot_metadata(for_meta_scrub, missing_digest); + // Called here on the primary can use an authoritative map if it isn't the primary + _scan_snaps(for_meta_scrub); if (!scrubber.store->empty()) { if (state_test(PG_STATE_REPAIR)) { dout(10) << __func__ << ": discarding scrub results" << dendl; diff --git a/src/osd/PG.h b/src/osd/PG.h index 40205c8e79e94..9e6fe7cb5f7bb 100644 --- a/src/osd/PG.h +++ b/src/osd/PG.h @@ -1593,6 +1593,26 @@ public: // Cleaned map pending snap metadata scrub ScrubMap cleaned_meta_map; + void clean_meta_map(ScrubMap &for_meta_scrub) { + if (end.is_max() || + cleaned_meta_map.objects.empty()) { + cleaned_meta_map.swap(for_meta_scrub); + } else { + auto iter = cleaned_meta_map.objects.end(); + --iter; // not empty, see if clause + auto begin = cleaned_meta_map.objects.begin(); + while (iter != begin) { + auto next = iter--; + if (next->first.get_head() != iter->first.get_head()) { + ++iter; + break; + } + } + for_meta_scrub.objects.insert(begin, iter); + cleaned_meta_map.objects.erase(begin, iter); + } + } + // digest updates which we are waiting on int num_digest_updates_pending; -- 2.39.5