From 5c00f116c2ecc351e9ccc729f4bf1c9869708860 Mon Sep 17 00:00:00 2001 From: Alex Ainscow Date: Tue, 10 Jun 2025 11:46:43 +0100 Subject: [PATCH] osd/scrub: Scrub should not expect SS_ATTR on non-primary shards Signed-off-by: Alex Ainscow (cherry picked from commit 6bae0a058ce3336aa4c1d1e2d204b25ac4d30cbb) --- src/osd/scrubber/scrub_backend.cc | 72 ++++++++++++++++--------------- 1 file changed, 37 insertions(+), 35 deletions(-) diff --git a/src/osd/scrubber/scrub_backend.cc b/src/osd/scrubber/scrub_backend.cc index dcabb3476c65c..ea1eeeda6f738 100644 --- a/src/osd/scrubber/scrub_backend.cc +++ b/src/osd/scrubber/scrub_backend.cc @@ -1809,50 +1809,52 @@ std::vector ScrubBackend::scan_snaps( // in this function dout(15) << "_scan_snaps starts" << dendl; - for (auto i = smap.objects.rbegin(); i != smap.objects.rend(); ++i) { + if (!m_pg.get_is_nonprimary_shard(m_pg_whoami)) { + for (auto i = smap.objects.rbegin(); i != smap.objects.rend(); ++i) { - const hobject_t& hoid = i->first; - ScrubMap::object& o = i->second; + const hobject_t& hoid = i->first; + ScrubMap::object& o = i->second; - dout(20) << __func__ << " " << hoid << dendl; + dout(20) << __func__ << " " << hoid << dendl; - ceph_assert(!hoid.is_snapdir()); + ceph_assert(!hoid.is_snapdir()); - if (hoid.is_head()) { - // parse the SnapSet - if (o.attrs.find(SS_ATTR) == o.attrs.end()) { - // no snaps for this head - continue; - } - auto p = o.attrs[SS_ATTR].cbegin(); - try { - decode(snapset, p); - } catch (...) { - dout(20) << fmt::format("{}: failed to decode the snapset ({})", - __func__, - hoid) - << dendl; - continue; + if (hoid.is_head()) { + // parse the SnapSet + if (o.attrs.find(SS_ATTR) == o.attrs.end()) { + // no snaps for this head + continue; + } + auto p = o.attrs[SS_ATTR].cbegin(); + try { + decode(snapset, p); + } catch (...) { + dout(20) << fmt::format("{}: failed to decode the snapset ({})", + __func__, + hoid) + << dendl; + continue; + } + head = hoid.get_head(); + continue; } - head = hoid.get_head(); - continue; - } - /// \todo document why guaranteed to have initialized 'head' at this point + /// \todo document why guaranteed to have initialized 'head' at this point - if (hoid.snap < CEPH_MAXSNAP) { + if (hoid.snap < CEPH_MAXSNAP) { - if (hoid.get_head() != head) { - derr << __func__ << " no head for " << hoid << " (have " << head << ")" - << dendl; - continue; - } + if (hoid.get_head() != head) { + derr << __func__ << " no head for " << hoid << " (have " << head << ")" + << dendl; + continue; + } - // the 'hoid' is a clone hoid at this point. The 'snapset' below was taken - // from the corresponding head hoid. - auto maybe_fix_order = scan_object_snaps(hoid, snapset, snaps_getter); - if (maybe_fix_order) { - out_orders.push_back(std::move(*maybe_fix_order)); + // the 'hoid' is a clone hoid at this point. The 'snapset' below was taken + // from the corresponding head hoid. + auto maybe_fix_order = scan_object_snaps(hoid, snapset, snaps_getter); + if (maybe_fix_order) { + out_orders.push_back(std::move(*maybe_fix_order)); + } } } } -- 2.39.5