]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: adjust MDSRank::incarnation according to mdsmap 6003/head
authorYan, Zheng <zyan@redhat.com>
Mon, 21 Sep 2015 07:20:15 +0000 (15:20 +0800)
committerYan, Zheng <zyan@redhat.com>
Mon, 21 Sep 2015 07:42:10 +0000 (15:42 +0800)
When a standby-replay MDS replace failed MDS, we need update its
incarnation.

Fixes: #13166
Signed-off-by: Yan, Zheng <zyan@redhat.com>
src/mds/MDSDaemon.cc
src/mds/MDSRank.cc
src/mds/MDSRank.h

index 6ecee035c8cd0af1b842d6c0f0c7f8d5a6b70a8c..6e3c42194c8d5fcb8b5a8c3321e89ac5bed4a96f 100644 (file)
@@ -911,7 +911,7 @@ void MDSDaemon::handle_mds_map(MMDSMap *m)
 
     // Did I previously not hold a rank?  Initialize!
     if (mds_rank == NULL) {
-      mds_rank = new MDSRankDispatcher(whoami, incarnation, mds_lock, clog,
+      mds_rank = new MDSRankDispatcher(whoami, mds_lock, clog,
           timer, beacon, mdsmap, messenger, monc, objecter,
           new C_VoidFn(this, &MDSDaemon::respawn),
           new C_VoidFn(this, &MDSDaemon::suicide));
index 8c04b2f3fde15f828c2c4c8d19104f756e8f51e8..0bc0f8413afd88c6d7b8546624e0e97ef87dc45f 100644 (file)
@@ -40,7 +40,6 @@
 
 MDSRank::MDSRank(
     mds_rank_t whoami_,
-    int incarnation_,
     Mutex &mds_lock_,
     LogChannelRef &clog_,
     SafeTimer &timer_,
@@ -52,8 +51,7 @@ MDSRank::MDSRank(
     Context *respawn_hook_,
     Context *suicide_hook_)
   :
-    whoami(whoami_),
-    incarnation(incarnation_),
+    whoami(whoami_), incarnation(0),
     mds_lock(mds_lock_), clog(clog_), timer(timer_),
     mdsmap(mdsmap_),
     objecter(objecter_),
@@ -1369,10 +1367,11 @@ void MDSRankDispatcher::handle_mds_map(
   assert(whoami != MDS_RANK_NONE);
 
   MDSMap::DaemonState oldstate = state;
-  state = mdsmap->get_state_gid(mds_gid_t(
-        monc->get_global_id()));
+  mds_gid_t mds_gid = mds_gid_t(monc->get_global_id());
+  state = mdsmap->get_state_gid(mds_gid);
   if (state != oldstate) {
     last_state = oldstate;
+    incarnation = mdsmap->get_inc_gid(mds_gid);
   }
 
   version_t epoch = m->get_epoch();
@@ -1417,9 +1416,9 @@ void MDSRankDispatcher::handle_mds_map(
   if (oldstate != state) {
     // update messenger.
     if (state == MDSMap::STATE_STANDBY_REPLAY || state == MDSMap::STATE_ONESHOT_REPLAY) {
-      dout(1) << "handle_mds_map i am now mds." << monc->get_global_id() << "." << incarnation
-             << "replaying mds." << whoami << "." << incarnation << dendl;
-      messenger->set_myname(entity_name_t::MDS(monc->get_global_id()));
+      dout(1) << "handle_mds_map i am now mds." << mds_gid << "." << incarnation
+             << " replaying mds." << whoami << "." << incarnation << dendl;
+      messenger->set_myname(entity_name_t::MDS(mds_gid));
     } else {
       dout(1) << "handle_mds_map i am now mds." << whoami << "." << incarnation << dendl;
       messenger->set_myname(entity_name_t::MDS(whoami));
@@ -2370,7 +2369,6 @@ bool MDSRankDispatcher::handle_command_legacy(std::vector<std::string> args)
 
 MDSRankDispatcher::MDSRankDispatcher(
     mds_rank_t whoami_,
-    int incarnation_,
     Mutex &mds_lock_,
     LogChannelRef &clog_,
     SafeTimer &timer_,
@@ -2381,7 +2379,7 @@ MDSRankDispatcher::MDSRankDispatcher(
     Objecter *objecter_,
     Context *respawn_hook_,
     Context *suicide_hook_)
-  : MDSRank(whoami_, incarnation_, mds_lock_, clog_, timer_, beacon_, mdsmap_,
+  : MDSRank(whoami_, mds_lock_, clog_, timer_, beacon_, mdsmap_,
       msgr, monc_, objecter_, respawn_hook_, suicide_hook_)
 {}
 
index fda2dfa460590532cf19eec4b3e2c80361ddfdd5..b999657a0ad7473e1baec15227e8e0e7a3bc3231 100644 (file)
@@ -119,7 +119,7 @@ class MDSRank {
 
     // Incarnation as seen in MDSMap at the point where a rank is
     // assigned.
-    const int incarnation;
+    int incarnation;
 
   public:
     mds_rank_t get_nodeid() const { return whoami; }
@@ -265,7 +265,6 @@ class MDSRank {
 
     MDSRank(
         mds_rank_t whoami_,
-        int incarnation_,
         Mutex &mds_lock_,
         LogChannelRef &clog_,
         SafeTimer &timer_,
@@ -496,7 +495,6 @@ public:
 
   MDSRankDispatcher(
       mds_rank_t whoami_,
-      int incarnation_,
       Mutex &mds_lock_,
       LogChannelRef &clog_,
       SafeTimer &timer_,