]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: MDSMonitor: implement 'get_trim_to()' to let the mon trim mdsmaps
authorJoao Eduardo Luis <joao.luis@inktank.com>
Wed, 4 Dec 2013 17:49:10 +0000 (17:49 +0000)
committerJoao Eduardo Luis <joao.luis@inktank.com>
Thu, 5 Dec 2013 17:47:37 +0000 (17:47 +0000)
This commit also adds two options to the MDSMonitor:

  - mon_max_mdsmap_epochs: the maximum amount of maps we'll keep (def: 500)
  - mon_mds_force_trim: the version we want to trim to

This results in 'get_trim_to()' returning the possible values:

  - if we have set mon_mds_force_trim, and this value is greater than the
    last committed version, trim to mon_mds_force_trim
  - if we hold more than the max number of maps, trim to last - max
  - if we have set mon_mds_force_trim and if we hold more than the max
    number of maps, and mon_mds_force_trim is lower than last - max,
    then trim to last - max

Backport: dumpling
Backport: emperor

Signed-off-by: Joao Eduardo Luis <joao.luis@inktank.com>
src/common/config_opts.h
src/mon/MDSMonitor.cc
src/mon/MDSMonitor.h

index 0d03809777759ef295a5fb64e66964ac923ed59d..b8085f86372e96ed1f2f08eb91d21cb3f03354d2 100644 (file)
@@ -170,6 +170,7 @@ OPTION(mon_force_standby_active, OPT_BOOL, true) // should mons force standby-re
 OPTION(mon_min_osdmap_epochs, OPT_INT, 500)
 OPTION(mon_max_pgmap_epochs, OPT_INT, 500)
 OPTION(mon_max_log_epochs, OPT_INT, 500)
+OPTION(mon_max_mdsmap_epochs, OPT_INT, 500)
 OPTION(mon_max_osd, OPT_INT, 10000)
 OPTION(mon_probe_timeout, OPT_DOUBLE, 2.0)
 OPTION(mon_slurp_timeout, OPT_DOUBLE, 10.0)
@@ -191,6 +192,7 @@ OPTION(mon_inject_sync_get_chunk_delay, OPT_DOUBLE, 0)  // inject N second delay
 OPTION(mon_osd_min_down_reporters, OPT_INT, 1)   // number of OSDs who need to report a down OSD for it to count
 OPTION(mon_osd_min_down_reports, OPT_INT, 3)     // number of times a down OSD must be reported for it to count
 OPTION(mon_osd_force_trim_to, OPT_INT, 0)   // force mon to trim maps to this point, regardless of min_last_epoch_clean (dangerous, use with care)
+OPTION(mon_mds_force_trim_to, OPT_INT, 0)   // force mon to trim mdsmaps to this point (dangerous, use with care)
 
 // dump transactions
 OPTION(mon_debug_dump_transactions, OPT_BOOL, false)
index 600a41059cecbc13e681506dec6c80e391baf0c6..df9e23e36264765aa8ce53e7aca1dccbc98f0bb8 100644 (file)
@@ -137,6 +137,24 @@ void MDSMonitor::encode_pending(MonitorDBStore::Transaction *t)
   put_last_committed(t, pending_mdsmap.epoch);
 }
 
+version_t MDSMonitor::get_trim_to()
+{
+  version_t floor = 0;
+  if (g_conf->mon_mds_force_trim_to > 0 &&
+      g_conf->mon_mds_force_trim_to < (int)get_last_committed()) {
+    floor = g_conf->mon_mds_force_trim_to;
+    dout(10) << __func__ << " explicit mon_mds_force_trim_to = "
+             << floor << dendl;
+  }
+
+  unsigned max = g_conf->mon_max_mdsmap_epochs;
+  version_t last = get_last_committed();
+
+  if (last - get_first_committed() > max && floor < last - max)
+    return last - max;
+  return floor;
+}
+
 void MDSMonitor::update_logger()
 {
   dout(10) << "update_logger" << dendl;
index 10d8d7b4213c961307dcb38b89198567bbcd1fe0..901e93e379b7fe1c6dde618c0b5fd2bb1450fc31 100644 (file)
@@ -65,6 +65,7 @@ class MDSMonitor : public PaxosService {
 
   void create_new_fs(MDSMap &m, int metadata_pool, int data_pool);
 
+  version_t get_trim_to();
 
   // service methods
   void create_initial();