]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: use TYPE_SEC for mon_scrub_interval 38457/head
authorKefu Chai <kchai@redhat.com>
Sun, 6 Dec 2020 08:02:33 +0000 (16:02 +0800)
committerKefu Chai <kchai@redhat.com>
Sun, 6 Dec 2020 08:30:45 +0000 (16:30 +0800)
* common/legacy_config_opts.h: drop mon_scrub_interval from legacy
  settings. as this option is not in critical path. so we can afford
  the overhead of look its value up in the map.
* common/options.cc: change mon_scrub_interval's type from TYPE_INT
  to TYPE_SECS, so we can use human friendly representations like
  "3 days" when specifying its value
* mon/Monitor.cc: adapt to the changes above.
* doc/rados: update the doc for "mon scrub interval" accordingly

Signed-off-by: Kefu Chai <kchai@redhat.com>
doc/rados/configuration/mon-config-ref.rst
src/common/legacy_config_opts.h
src/common/options.cc
src/mon/Monitor.cc
src/mon/Monitor.h

index 333b0f9b3a47ec56be7ff6462e5bb3cb76484a91..2edbdd0ba2e76998dd731ec179637548646678b4 100644 (file)
@@ -1119,12 +1119,12 @@ Miscellaneous
 
 ``mon scrub interval``
 
-:Description: How often (in seconds) the monitor scrub its store by comparing
+:Description: How often the monitor scrub its store by comparing
               the stored checksums with the computed ones of all the stored
-              keys.
+              keys. (0 disables it. dangerous, use with care)
 
-:Type: Integer
-:Default: ``3600*24``
+:Type: Seconds
+:Default: ``1 day``
 
 
 ``mon scrub max keys``
index 8539b353bb1f83a800fc7b45bd01cac86835aa9b..162b324fdaa85c5d2541b3ec0050fa7994a9422f 100644 (file)
@@ -269,7 +269,6 @@ OPTION(mon_data_avail_warn, OPT_INT)
 OPTION(mon_data_size_warn, OPT_U64) // issue a warning when the monitor's data store goes over 15GB (in bytes)
 OPTION(mon_warn_pg_not_scrubbed_ratio, OPT_FLOAT)
 OPTION(mon_warn_pg_not_deep_scrubbed_ratio, OPT_FLOAT)
-OPTION(mon_scrub_interval, OPT_INT) // once a day
 OPTION(mon_scrub_timeout, OPT_INT) // let's give it 5 minutes; why not.
 OPTION(mon_scrub_max_keys, OPT_INT) // max number of keys to scrub each time
 OPTION(mon_scrub_inject_crc_mismatch, OPT_DOUBLE) // probability of injected crc mismatch [0.0, 1.0]
index 1102696a5da5cdea2d4590af6f815cdeb3ed3fce..367e52ee0dba2e127731c9875fb6f9e6c6813c83 100644 (file)
@@ -1996,7 +1996,7 @@ std::vector<Option> get_global_options() {
     .set_long_description("")
     .add_see_also("osd_deep_scrub_interval"),
 
-    Option("mon_scrub_interval", Option::TYPE_INT, Option::LEVEL_ADVANCED)
+    Option("mon_scrub_interval", Option::TYPE_SECS, Option::LEVEL_ADVANCED)
     .set_default(1_day)
     .add_service("mon")
     .set_description("frequency for scrubbing mon database"),
index 66d3a190efbf217d51e7c875e41140dbcf4a5fd2..2a049997a19be56d519f71e207649b53f68dfff3 100644 (file)
@@ -657,7 +657,8 @@ void Monitor::handle_conf_change(const ConfigProxy& conf,
   }
 
   if (changed.count("mon_scrub_interval")) {
-    int scrub_interval = conf->mon_scrub_interval;
+    auto scrub_interval =
+      conf.get_val<std::chrono::seconds>("mon_scrub_interval");
     finisher.queue(new C_MonContext{this, [this, scrub_interval](int) {
       std::lock_guard l{lock};
       scrub_update_interval(scrub_interval);
@@ -5639,14 +5640,14 @@ void Monitor::scrub_reset()
   scrub_state.reset();
 }
 
-inline void Monitor::scrub_update_interval(int secs)
+inline void Monitor::scrub_update_interval(ceph::timespan interval)
 {
   // 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;
+  dout(1) << __func__ << " new interval = " << interval << dendl;
 
   // if scrub already in progress, all changes will already be visible during
   // the next round.  Nothing to do.
@@ -5664,15 +5665,17 @@ void Monitor::scrub_event_start()
   if (scrub_event)
     scrub_event_cancel();
 
-  if (cct->_conf->mon_scrub_interval <= 0) {
+  auto scrub_interval =
+    cct->_conf.get_val<std::chrono::seconds>("mon_scrub_interval");
+  if (scrub_interval == std::chrono::seconds::zero()) {
     dout(1) << __func__ << " scrub event is disabled"
-            << " (mon_scrub_interval = " << cct->_conf->mon_scrub_interval
+            << " (mon_scrub_interval = " << scrub_interval
             << ")" << dendl;
     return;
   }
 
   scrub_event = timer.add_event_after(
-    cct->_conf->mon_scrub_interval,
+    scrub_interval,
     new C_MonContext{this, [this](int) {
       scrub_start();
       }});
index 936af1ee91d4504d888ed71f34453b9b4bcfdec4..0bba7756ca2a20660e90b98d2e4d2807c00fa5bf 100644 (file)
@@ -298,7 +298,7 @@ private:
   void scrub_timeout();
   void scrub_finish();
   void scrub_reset();
-  void scrub_update_interval(int secs);
+  void scrub_update_interval(ceph::timespan interval);
 
   Context *scrub_event;       ///< periodic event to trigger scrub (leader)
   Context *scrub_timeout_event;  ///< scrub round timeout (leader)