From: wanwencong Date: Thu, 25 Feb 2021 09:07:41 +0000 (+0800) Subject: osd: fix scrub reschedule bug X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=bd2626ef9e3e1f5835545ceffbab95b46547c8b0;p=ceph.git osd: fix scrub reschedule bug not all element can be visited during reschedule traverse Fixes: https://tracker.ceph.com/issues/49487 Signed-off-by: wencong wan (cherry picked from commit d7561a6e58fc8043b77648a2cdd5d12bb637f92b) Conflicts: src/osd/OSD.cc (scrub vs scrub_job variable name, pg->scrubber vs pg->m_planned_scrub) src/osd/OSD.h (trivial: set vs std::set) --- diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index fc22af1cbdcdc..efeb034398461 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -8019,20 +8019,26 @@ void OSD::sched_scrub() void OSD::resched_all_scrubs() { dout(10) << __func__ << ": start" << dendl; - OSDService::ScrubJob scrub; - if (service.first_scrub_stamp(&scrub)) { - do { - dout(20) << __func__ << ": examine " << scrub.pgid << dendl; - - PGRef pg = _lookup_lock_pg(scrub.pgid); + const vector pgs = [this] { + vector pgs; + OSDService::ScrubJob job; + if (service.first_scrub_stamp(&job)) { + do { + pgs.push_back(job.pgid); + } while (service.next_scrub_stamp(job, &job)); + } + return pgs; + }(); + for (auto& pgid : pgs) { + dout(20) << __func__ << ": examine " << pgid << dendl; + PGRef pg = _lookup_lock_pg(pgid); if (!pg) continue; if (!pg->scrubber.must_scrub && !pg->scrubber.need_auto) { - dout(20) << __func__ << ": reschedule " << scrub.pgid << dendl; + dout(15) << __func__ << ": reschedule " << pgid << dendl; pg->on_info_history_change(); } pg->unlock(); - } while (service.next_scrub_stamp(scrub, &scrub)); } dout(10) << __func__ << ": done" << dendl; } diff --git a/src/osd/OSD.h b/src/osd/OSD.h index 8c87823d2da70..25d587cf7609a 100644 --- a/src/osd/OSD.h +++ b/src/osd/OSD.h @@ -483,10 +483,7 @@ public: std::lock_guard l(sched_scrub_lock); if (sched_scrub_pg.empty()) return false; - set::const_iterator iter = sched_scrub_pg.lower_bound(next); - if (iter == sched_scrub_pg.cend()) - return false; - ++iter; + std::set::const_iterator iter = sched_scrub_pg.upper_bound(next); if (iter == sched_scrub_pg.cend()) return false; *out = *iter;