From 59bc72d29263cca65f0b8a449d80462fc2ee041e Mon Sep 17 00:00:00 2001 From: Joao Eduardo Luis Date: Thu, 16 Apr 2015 00:34:10 +0100 Subject: [PATCH] mon: Monitor: schedule scrub periodically Default is 24h interval, adjustable via 'mon_scrub_interval'. Signed-off-by: Joao Eduardo Luis --- src/common/config_opts.h | 1 + src/mon/Monitor.cc | 24 ++++++++++++++++++++++++ src/mon/Monitor.h | 11 +++++++++++ 3 files changed, 36 insertions(+) diff --git a/src/common/config_opts.h b/src/common/config_opts.h index 7c4ca61e8d00..be0bf9732652 100644 --- a/src/common/config_opts.h +++ b/src/common/config_opts.h @@ -243,6 +243,7 @@ OPTION(mon_health_to_clog_tick_interval, OPT_DOUBLE, 60.0) OPTION(mon_data_avail_crit, OPT_INT, 5) OPTION(mon_data_avail_warn, OPT_INT, 30) OPTION(mon_data_size_warn, OPT_U64, 15*1024*1024*1024) // issue a warning when the monitor's data store goes over 15GB (in bytes) +OPTION(mon_scrub_interval, OPT_INT, 3600*24) // once a day OPTION(mon_config_key_max_entry_size, OPT_INT, 4096) // max num bytes per config-key entry OPTION(mon_sync_timeout, OPT_DOUBLE, 60.0) OPTION(mon_sync_max_payload_size, OPT_U32, 1048576) // max size for a sync chunk payload (say, 1MB) diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index 8d1b3ee786cd..0aba8ddbc4ae 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -165,7 +165,9 @@ Monitor::Monitor(CephContext* cct_, string nm, MonitorDBStore *s, required_features(0), leader(0), quorum_features(0), + // scrub scrub_version(0), + scrub_event(NULL), // sync state sync_provider_count(0), @@ -993,6 +995,7 @@ void Monitor::_reset() cancel_probe_timeout(); timecheck_finish(); health_events_cleanup(); + scrub_event_cancel(); leader_since = utime_t(); if (!quorum.empty()) { @@ -1856,6 +1859,7 @@ void Monitor::win_election(epoch_t epoch, set& active, uint64_t features, timecheck_start(); health_tick_start(); do_health_to_clog_interval(); + scrub_event_start(); } } @@ -4305,6 +4309,7 @@ void Monitor::scrub_finish() clog->info() << "scrub ok on " << quorum << ": " << mine << "\n"; scrub_reset(); + scrub_event_start(); } void Monitor::scrub_reset() @@ -4315,6 +4320,25 @@ void Monitor::scrub_reset() } +void Monitor::scrub_event_start() +{ + dout(10) << __func__ << dendl; + + if (scrub_event) + scrub_event_cancel(); + + scrub_event = new C_Scrub(this); + timer.add_event_after(cct->_conf->mon_scrub_interval, scrub_event); +} + +void Monitor::scrub_event_cancel() +{ + dout(10) << __func__ << dendl; + if (scrub_event) { + timer.cancel_event(scrub_event); + scrub_event = NULL; + } +} /************ TICK ***************/ diff --git a/src/mon/Monitor.h b/src/mon/Monitor.h index 72f1307602b4..7989d3dd5b97 100644 --- a/src/mon/Monitor.h +++ b/src/mon/Monitor.h @@ -248,6 +248,17 @@ private: void scrub_finish(); void scrub_reset(); + struct C_Scrub : public Context { + Monitor *mon; + C_Scrub(Monitor *m) : mon(m) { } + void finish(int r) { + mon->scrub(); + } + }; + Context *scrub_event; + void scrub_event_start(); + void scrub_event_cancel(); + /** * @defgroup Monitor_h_sync Synchronization * @{ -- 2.47.3