]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: Monitor: track scrub's state
authorJoao Eduardo Luis <joao@suse.de>
Thu, 16 Apr 2015 00:33:00 +0000 (01:33 +0100)
committerJoao Eduardo Luis <joao@suse.de>
Tue, 5 May 2015 11:24:28 +0000 (12:24 +0100)
Signed-off-by: Joao Eduardo Luis <joao@suse.de>
src/mon/Monitor.cc
src/mon/Monitor.h

index 0aba8ddbc4aec0724e77556aa0c80f629cf1e639..c12affdc24e1f6a3fe237952b9cce381048d51a2 100644 (file)
@@ -4271,11 +4271,17 @@ void Monitor::_scrub(ScrubResult *r)
 
   dout(10) << __func__ << " prefixes " << prefixes << dendl;
 
-  pair<string,string> start;
-  MonitorDBStore::Synchronizer synchronizer = store->get_synchronizer(start, prefixes);
+  if (scrub_state) {
+    dout(10) << __func__ << " scrub already in progress" << dendl;
+    return;
+  }
 
-  while (synchronizer->has_next_chunk()) {
-    pair<string,string> k = synchronizer->get_next_key();
+  scrub_state.reset(new ScrubState);
+  MonitorDBStore::Synchronizer it =
+    store->get_synchronizer(scrub_state->last_key, prefixes);
+
+  while (it->has_next_chunk()) {
+    pair<string,string> k = it->get_next_key();
     bufferlist bl;
     store->get(k.first, k.second, bl);
     dout(30) << __func__ << " " << k << " bl " << bl.length() << " bytes crc " << bl.crc32c(0) << dendl;
@@ -4284,6 +4290,9 @@ void Monitor::_scrub(ScrubResult *r)
       r->prefix_crc[k.first] = 0;
     r->prefix_crc[k.first] = bl.crc32c(r->prefix_crc[k.first]);
   }
+  scrub_state->last_key = it->get_last_key();
+
+  scrub_state.reset();
 }
 
 void Monitor::scrub_finish()
@@ -4317,6 +4326,7 @@ void Monitor::scrub_reset()
   dout(10) << __func__ << dendl;
   scrub_version = 0;
   scrub_result.clear();
+  scrub_state.reset();
 }
 
 
index 7989d3dd5b97c850ca74377c5d1d02778eec8188..578ddf50fb2cea08cc1099c61288bdda7e62fc57 100644 (file)
@@ -255,10 +255,18 @@ private:
       mon->scrub();
     }
   };
-  Context *scrub_event;
+  Context *scrub_event;       ///< periodic event to trigger scrub (leader)
   void scrub_event_start();
   void scrub_event_cancel();
 
+  struct ScrubState {
+    pair<string,string> last_key; ///< last scrubbed key
+
+    ScrubState() { }
+    virtual ~ScrubState() { }
+  };
+  ceph::shared_ptr<ScrubState> scrub_state; ///< keeps track of current scrub
+
   /**
    * @defgroup Monitor_h_sync Synchronization
    * @{