]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
MDS: Implement the hooks for standby_replay.
authorGreg Farnum <gregf@hq.newdream.net>
Wed, 1 Dec 2010 21:28:44 +0000 (13:28 -0800)
committerGreg Farnum <gregf@hq.newdream.net>
Thu, 6 Jan 2011 18:35:24 +0000 (10:35 -0800)
This commit adds the necessary state checks and machinery
for the MDS to go through a "looping" replay.
It does not yet implement online trimming, nor is there any
way to get the MDS into or out of a standby_replay state.

Signed-off-by: Greg Farnum <gregf@hq.newdream.net>
src/config.cc
src/config.h
src/mds/MDLog.h
src/mds/MDS.cc
src/mds/MDS.h

index 8b6cfd5ae2387958c6eebf78d5605f69e84157d9..7f94535a300b48d6040ba034712aee91bb80116a 100644 (file)
@@ -493,6 +493,7 @@ static struct config_option config_optionsp[] = {
        OPTION(mds_bal_minchunk, 0, OPT_FLOAT, .001),     // never take anything smaller than this
        OPTION(mds_bal_target_removal_min, 0, OPT_INT, 5), // min balance iterations before old target is removed
        OPTION(mds_bal_target_removal_max, 0, OPT_INT, 10), // max balance iterations before old target is removed
+       OPTION(mds_replay_interval, 0, OPT_FLOAT, 1.0), // time to wait before starting replay again
        OPTION(mds_trim_on_rejoin, 0, OPT_BOOL, true),
        OPTION(mds_shutdown_check, 0, OPT_INT, 0),
        OPTION(mds_verify_export_dirauth, 0, OPT_BOOL, true),
index f5853c144631154c514c8eb40ea7fb7ec5e342fd..c4d962b0ecdd2ed43770be204256b223d64bf214 100644 (file)
@@ -300,6 +300,8 @@ struct md_config_t {
   int mds_bal_target_removal_min;
   int mds_bal_target_removal_max;
 
+  float mds_replay_interval;
+
   bool  mds_trim_on_rejoin;
   int   mds_shutdown_check;
 
index fb88a6b252afed89a7910ae34c5b3d47b2496b72..74506b48acbe29a4f8df58fd9394e5fa416667b1 100644 (file)
@@ -178,6 +178,7 @@ public:
   uint64_t get_read_pos();
   uint64_t get_write_pos();
   uint64_t get_safe_pos();
+  Journaler *get_journaler() { return journaler; }
   bool empty() { return segments.empty(); }
 
   bool is_capped() { return capped; }
index 3fd5171331ed05288509b67f634178c31a4fe7f4..8968c5e24ff16ffe3e75df34d92fc34750184996 100644 (file)
@@ -23,6 +23,7 @@
 #include "osd/OSDMap.h"
 #include "osdc/Objecter.h"
 #include "osdc/Filer.h"
+#include "osdc/Journaler.h"
 
 #include "MDSMap.h"
 
@@ -897,7 +898,8 @@ void MDS::handle_mds_map(MMDSMap *m)
 
     if (is_active()) {
       active_start();
-    } else if (is_replay() || is_oneshot_replay()) {
+    } else if (is_replay() || is_oneshot_replay() ||
+        is_standby_replay()) {
       replay_start();
     } else if (is_resolve()) {
       resolve_start();
@@ -1130,7 +1132,7 @@ void MDS::boot_start(int step, int r)
     }
 
   case 3:
-    if (is_replay() || is_oneshot_replay()) {
+    if (is_replay() || is_oneshot_replay() || is_standby_replay()) {
       dout(2) << "boot_start " << step << ": replaying mds log" << dendl;
       mdlog->replay(new C_MDS_BootStart(this, 4));
       break;
@@ -1141,7 +1143,7 @@ void MDS::boot_start(int step, int r)
     }
 
   case 4:
-    if (is_replay() || is_oneshot_replay()) {
+    if (is_replay() || is_oneshot_replay() || is_standby_replay()) {
       replay_done();
       break;
     }
@@ -1196,6 +1198,22 @@ void MDS::replay_start()
   }
 }
 
+
+inline void MDS::standby_replay_restart()
+{
+  mdlog->get_journaler()->reread_head_and_probe(new C_MDS_BootStart(this, 3));
+}
+
+class MDS::C_Standby_replay_start : public Context {
+  MDS *mds;
+public:
+  C_Standby_replay_start(MDS *m) : mds(m) {}
+  void finish(int r) {
+    assert(!r);
+    mds->standby_replay_restart();
+  }
+};
+
 void MDS::replay_done()
 {
   dout(1) << "replay_done in=" << mdsmap->get_num_mds()
@@ -1208,6 +1226,13 @@ void MDS::replay_done()
     return;
   }
 
+  if (is_standby_replay()) {
+    standby_trim_segments();
+    timer.add_event_after(g_conf.mds_replay_interval,
+                          new C_Standby_replay_start(this));
+    return;
+  }
+
   if (g_conf.mds_wipe_sessions) {
     dout(1) << "wiping out client sessions" << dendl;
     sessionmap.wipe();
@@ -1235,6 +1260,11 @@ void MDS::replay_done()
   }
 }
 
+void MDS::standby_trim_segments()
+{
+  return;
+}
+
 
 void MDS::resolve_start()
 {
index 1df0b998d40d32677d9d18fac6e471a2d03352dc..5f05f185f0c737fb2e91d991b6e61ec9dd7b9c15 100644 (file)
@@ -218,6 +218,7 @@ class MDS : public Dispatcher {
   bool is_starting() { return state == MDSMap::STATE_STARTING; }
   bool is_standby()  { return state == MDSMap::STATE_STANDBY; }
   bool is_replay()   { return state == MDSMap::STATE_REPLAY; }
+  bool is_standby_replay() { return state == MDSMap::STATE_STANDBY_REPLAY; }
   bool is_resolve()  { return state == MDSMap::STATE_RESOLVE; }
   bool is_reconnect() { return state == MDSMap::STATE_RECONNECT; }
   bool is_rejoin()   { return state == MDSMap::STATE_REJOIN; }
@@ -353,6 +354,9 @@ class MDS : public Dispatcher {
   void creating_done();
   void starting_done();
   void replay_done();
+  void standby_replay_restart();
+  void standby_trim_segments();
+  class C_Standby_replay_start;
 
   void resolve_start();
   void resolve_done();