]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: Monitor: allow updating scrub interval on demand 4587/head
authorJoao Eduardo Luis <joao@suse.de>
Tue, 26 May 2015 15:00:24 +0000 (16:00 +0100)
committerJoao Eduardo Luis <joao@suse.de>
Wed, 27 May 2015 22:48:45 +0000 (23:48 +0100)
The interval, by default, is 3600*60 seconds (1 day).  When we start the
monitor we set the event to trigger a scrub after said time has passed.
If a user injects a different interval, we would have to wait a full day
until it took effect; this way it doesn't.

Signed-off-by: Joao Eduardo Luis <joao@suse.de>
src/mon/Monitor.cc
src/mon/Monitor.h

index c16c2c724507ce351efe3e2386fea7c65b132ded..d31e0abd796f834eeb2d1b9dc691c07dc5dfe232 100644 (file)
@@ -452,6 +452,8 @@ const char** Monitor::get_tracked_conf_keys() const
     "mon_health_to_clog",
     "mon_health_to_clog_interval",
     "mon_health_to_clog_tick_interval",
+    // scrub interval
+    "mon_scrub_interval",
     NULL
   };
   return KEYS;
@@ -476,6 +478,10 @@ void Monitor::handle_conf_change(const struct md_config_t *conf,
       changed.count("mon_health_to_clog_tick_interval")) {
     health_to_clog_update_conf(changed);
   }
+
+  if (changed.count("mon_scrub_interval")) {
+    scrub_update_interval(conf->mon_scrub_interval);
+  }
 }
 
 void Monitor::update_log_clients()
@@ -4210,6 +4216,7 @@ int Monitor::scrub_start()
     return -EBUSY;
   }
 
+  scrub_event_cancel();
   scrub_result.clear();
   scrub_state.reset(new ScrubState);
 
@@ -4424,6 +4431,23 @@ void Monitor::scrub_reset()
   scrub_state.reset();
 }
 
+inline void Monitor::scrub_update_interval(int secs)
+{
+  // we don't care about changes if we are not the leader.
+  // changes will be visible if we become the leader.
+  if (!is_leader())
+    return;
+
+  dout(1) << __func__ << " new interval = " << secs << dendl;
+
+  // if scrub already in progress, all changes will already be visible during
+  // the next round.  Nothing to do.
+  if (scrub_state != NULL)
+    return;
+
+  scrub_event_cancel();
+  scrub_event_start();
+}
 
 void Monitor::scrub_event_start()
 {
@@ -4432,6 +4456,13 @@ void Monitor::scrub_event_start()
   if (scrub_event)
     scrub_event_cancel();
 
+  if (cct->_conf->mon_scrub_interval <= 0) {
+    dout(1) << __func__ << " scrub event is disabled"
+            << " (mon_scrub_interval = " << cct->_conf->mon_scrub_interval
+            << ")" << dendl;
+    return;
+  }
+
   scrub_event = new C_Scrub(this);
   timer.add_event_after(cct->_conf->mon_scrub_interval, scrub_event);
 }
index 204aabf53c21a02069ef1fc85b2012f1fb086b9a..dd64f9028bb1402327f2c3cb7781693098d6d020 100644 (file)
@@ -252,6 +252,7 @@ private:
   void scrub_timeout();
   void scrub_finish();
   void scrub_reset();
+  void scrub_update_interval(int secs);
 
   struct C_Scrub : public Context {
     Monitor *mon;