From: Joao Eduardo Luis Date: Thu, 16 Apr 2015 00:33:00 +0000 (+0100) Subject: mon: Monitor: track scrub's state X-Git-Tag: v9.0.3~18^2~7 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=cdb37dcc1c1fad1d890b73716251b1e3c97d92c4;p=ceph.git mon: Monitor: track scrub's state Signed-off-by: Joao Eduardo Luis --- diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index 0aba8ddbc4ae..c12affdc24e1 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -4271,11 +4271,17 @@ void Monitor::_scrub(ScrubResult *r) dout(10) << __func__ << " prefixes " << prefixes << dendl; - pair 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 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 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(); } diff --git a/src/mon/Monitor.h b/src/mon/Monitor.h index 7989d3dd5b97..578ddf50fb2c 100644 --- a/src/mon/Monitor.h +++ b/src/mon/Monitor.h @@ -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 last_key; ///< last scrubbed key + + ScrubState() { } + virtual ~ScrubState() { } + }; + ceph::shared_ptr scrub_state; ///< keeps track of current scrub + /** * @defgroup Monitor_h_sync Synchronization * @{