]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: fix scrub reschedule bug 41973/head
authorwanwencong <wanwc@chinatelecom.cn>
Thu, 25 Feb 2021 09:07:41 +0000 (17:07 +0800)
committerMykola Golub <mgolub@suse.com>
Tue, 22 Jun 2021 11:22:27 +0000 (14:22 +0300)
not all element can be visited during reschedule traverse

Fixes: https://tracker.ceph.com/issues/49487
Signed-off-by: wencong wan <wanwc@chinatelecom.cn>
(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)

src/osd/OSD.cc
src/osd/OSD.h

index fc22af1cbdcdc8f8e6b2184af82dd1bd9fef32e2..efeb034398461ee110fcf49ab4b9f80edfb93657 100644 (file)
@@ -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<spg_t> pgs = [this] {
+    vector<spg_t> 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;
 }
index 8c87823d2da70832c340e7f89171c4dcbb796e15..25d587cf7609a8c84f9363fe17bdd9968621b9bc 100644 (file)
@@ -483,10 +483,7 @@ public:
     std::lock_guard l(sched_scrub_lock);
     if (sched_scrub_pg.empty())
       return false;
-    set<ScrubJob>::const_iterator iter = sched_scrub_pg.lower_bound(next);
-    if (iter == sched_scrub_pg.cend())
-      return false;
-    ++iter;
+    std::set<ScrubJob>::const_iterator iter = sched_scrub_pg.upper_bound(next);
     if (iter == sched_scrub_pg.cend())
       return false;
     *out = *iter;