From: Joao Eduardo Luis Date: Tue, 26 May 2015 15:00:24 +0000 (+0100) Subject: mon: Monitor: allow updating scrub interval on demand X-Git-Tag: v9.0.3~18^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=29349090c2cf5d1a5d0c66c95835c10f7b6093d1;p=ceph.git mon: Monitor: allow updating scrub interval on demand 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 --- diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index c16c2c724507..d31e0abd796f 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -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); } diff --git a/src/mon/Monitor.h b/src/mon/Monitor.h index 204aabf53c21..dd64f9028bb1 100644 --- a/src/mon/Monitor.h +++ b/src/mon/Monitor.h @@ -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;