]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: fix scrub reschedule bug 41972/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:16:56 +0000 (14:16 +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 8ae62212e35999bcb31dec4a257abaa71e0b0cf2..b56c41a4334da26fda0255837283ab159c312448 100644 (file)
@@ -7511,20 +7511,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 b7a45f8c9f498375f5088a3b0ac2aaf1e40d7104..e277554beae6b2c30113e460932a32d2dc642823 100644 (file)
@@ -325,10 +325,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;