]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: fix scrub scheduling for 0.0
authorSage Weil <sage@inktank.com>
Tue, 15 Jan 2013 02:20:29 +0000 (18:20 -0800)
committerSage Weil <sage@inktank.com>
Tue, 15 Jan 2013 03:20:53 +0000 (19:20 -0800)
The initial value for pair<utime_t,pg_t> can match pg 0.0, preventing it
from being manually scrubbed.  Fix!

Signed-off-by: Sage Weil <sage@inktank.com>
src/osd/OSD.cc
src/osd/OSD.h

index 70c89f7c317ba3570a4a244ae9d94f77328a40dd..a0e2a2edae351ea0b86ed932c9519a249488eaa8 100644 (file)
@@ -3575,37 +3575,40 @@ void OSD::sched_scrub()
   //dout(20) << " " << last_scrub_pg << dendl;
 
   pair<utime_t, pg_t> pos;
-  while (service.next_scrub_stamp(pos, &pos)) {
-    utime_t t = pos.first;
-    pg_t pgid = pos.second;
+  if (service.first_scrub_stamp(&pos)) {
+    do {
+      utime_t t = pos.first;
+      pg_t pgid = pos.second;
+      dout(30) << " " << pgid << " at " << t << dendl;
 
-    if (t > min) {
-      dout(10) << " " << pgid << " at " << t
-              << " > min " << min << " (" << g_conf->osd_scrub_min_interval << " seconds ago)" << dendl;
-      break;
-    }
-    if (t > max && !load_is_low) {
-      // save ourselves some effort
-      break;
-    }
-
-    PG *pg = _lookup_lock_pg(pgid);
-    if (pg) {
-      if (pg->is_active() &&
-         (load_is_low ||
-          t < max ||
-          pg->scrubber.must_scrub)) {
+      if (t > min) {
        dout(10) << " " << pgid << " at " << t
-                << (pg->scrubber.must_scrub ? ", explicitly requested" : "")
-                << (t < max ? ", last_scrub > max" : "")
-                << dendl;
-       if (pg->sched_scrub()) {
-         pg->unlock();
-         break;
+                << " > min " << min << " (" << g_conf->osd_scrub_min_interval << " seconds ago)" << dendl;
+       break;
+      }
+      if (t > max && !load_is_low) {
+       // save ourselves some effort
+       break;
+      }
+
+      PG *pg = _lookup_lock_pg(pgid);
+      if (pg) {
+       if (pg->is_active() &&
+           (load_is_low ||
+            t < max ||
+            pg->scrubber.must_scrub)) {
+         dout(10) << " " << pgid << " at " << t
+                  << (pg->scrubber.must_scrub ? ", explicitly requested" : "")
+                  << (t < max ? ", last_scrub < max" : "")
+                  << dendl;
+         if (pg->sched_scrub()) {
+           pg->unlock();
+           break;
+         }
        }
+       pg->unlock();
       }
-      pg->unlock();
-    }
+    } while  (service.next_scrub_stamp(pos, &pos));
   }    
   dout(20) << "sched_scrub done" << dendl;
 }
index d578ff38c2ef8e2fc686597c35e757f1aafe2d1e..83308486f0f2487cb1929ed997abf859d598affd 100644 (file)
@@ -255,17 +255,29 @@ public:
   void unreg_last_pg_scrub(pg_t pgid, utime_t t) {
     Mutex::Locker l(sched_scrub_lock);
     pair<utime_t,pg_t> p(t, pgid);
-    assert(last_scrub_pg.count(p));
-    last_scrub_pg.erase(p);
+    set<pair<utime_t,pg_t> >::iterator it = last_scrub_pg.find(p);
+    assert(it != last_scrub_pg.end());
+    last_scrub_pg.erase(it);
   }
-  bool next_scrub_stamp(pair<utime_t, pg_t> after,
+  bool first_scrub_stamp(pair<utime_t, pg_t> *out) {
+    Mutex::Locker l(sched_scrub_lock);
+    if (last_scrub_pg.size() == 0)
+      return false;
+    set< pair<utime_t, pg_t> >::iterator iter = last_scrub_pg.begin();
+    *out = *iter;
+    return true;
+  }
+  bool next_scrub_stamp(pair<utime_t, pg_t> next,
                        pair<utime_t, pg_t> *out) {
     Mutex::Locker l(sched_scrub_lock);
-    if (last_scrub_pg.size() == 0) return false;
-    set< pair<utime_t, pg_t> >::iterator iter = last_scrub_pg.lower_bound(after);
-    if (iter == last_scrub_pg.end()) return false;
+    if (last_scrub_pg.size() == 0)
+      return false;
+    set< pair<utime_t, pg_t> >::iterator iter = last_scrub_pg.lower_bound(next);
+    if (iter == last_scrub_pg.end())
+      return false;
     ++iter;
-    if (iter == last_scrub_pg.end()) return false;
+    if (iter == last_scrub_pg.end())
+      return false;
     *out = *iter;
     return true;
   }