]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: simplify mds follow checks
authorSage Weil <sage.weil@dreamhost.com>
Tue, 12 Apr 2011 21:13:56 +0000 (14:13 -0700)
committerSage Weil <sage.weil@dreamhost.com>
Tue, 12 Apr 2011 21:13:56 +0000 (14:13 -0700)
Instead of assigning followers in the last_beacon laggy check loop, do it
at the end, the same way we let standby nodes take over.

This also fixes a bug where a non-standby node (say, up:replay) that used
to be up:standby-replay and has standby_for_rank set gets reset back to
up:standby-replay.

Fixes: #1001
Signed-off-by: Sage Weil <sage.weil@dreamhost.com>
src/mon/MDSMonitor.cc

index 36cf8a02d3fc6b0793dafcc75239b1ca2e3f3211..96508f99710373dc54fcf685718f46bafb82c007 100644 (file)
@@ -927,42 +927,11 @@ void MDSMonitor::tick()
        continue;
       }
 
-      if (since >= cutoff && pending_mdsmap.mds_info[gid].standby_for_rank != MDSMap::MDS_STANDBY_ANY)
+      if (since >= cutoff)
        continue;
 
-
       MDSMap::mds_info_t& info = pending_mdsmap.mds_info[gid];
 
-      if (since >= cutoff && info.standby_for_rank == MDSMap::MDS_STANDBY_ANY) {
-        /* this mds is not laggy, but has no rank assigned.
-         * See if we can find it somebody to shadow
-         */
-        int gid = 0;
-        for (map<uint64_t,MDSMap::mds_info_t>::iterator i = pending_mdsmap.mds_info.begin();
-            i != pending_mdsmap.mds_info.end();
-            ++i) {
-          if (i->second.rank >= 0 &&
-             mdsmap.is_followable(i->second.rank)) {
-            if ((gid = pending_mdsmap.find_standby_for(
-                i->second.rank, i->second.name))) {
-              dout(20) << "checking rank " << i->second.rank << dendl;
-              dout(20) << "follower gid" << gid << "has state"
-                  << ceph_mds_state_name(pending_mdsmap.get_info_gid(gid).state) << dendl;
-              if (pending_mdsmap.get_info_gid(gid).state == MDSMap::STATE_STANDBY_REPLAY) {
-                dout(20) << "skipping this MDS since it has a follower!" << dendl;
-                continue; // this MDS already has a standby
-              }
-            }
-            // hey, we found an MDS without a standby. Pair them!
-            info.standby_for_rank = i->second.rank;
-            dout(10) << "setting to shadow mds rank " << info.standby_for_rank << dendl;
-            info.state = MDSMap::STATE_STANDBY_REPLAY;
-            do_propose = true;
-            break;
-          }
-        }
-        continue;
-      }
       dout(10) << "no beacon from " << gid << " " << info.addr << " mds" << info.rank << "." << info.inc
               << " " << ceph_mds_state_name(info.state)
               << " since " << since << dendl;
@@ -1070,6 +1039,50 @@ void MDSMonitor::tick()
     }
   }
 
+  // have a standby follow someone?
+  if (failed.empty()) {
+    for (map<uint64_t,MDSMap::mds_info_t>::iterator j = pending_mdsmap.mds_info.begin();
+        j != pending_mdsmap.mds_info.end();
+        ++j) {
+      MDSMap::mds_info_t& info = j->second;
+      
+      if (info.state != MDSMap::STATE_STANDBY ||
+         info.standby_for_rank != MDSMap::MDS_STANDBY_ANY)
+       continue;
+
+      /*
+       * This mds is standby but has no rank assigned.
+       * See if we can find it somebody to shadow
+       */
+      dout(20) << "gid " << j->first << " is standby and following nobody" << dendl;
+      
+      uint64_t lgid = 0;
+      for (map<uint64_t,MDSMap::mds_info_t>::iterator i = pending_mdsmap.mds_info.begin();
+          i != pending_mdsmap.mds_info.end();
+          ++i) {
+       if (i->second.rank >= 0 && pending_mdsmap.is_followable(i->second.rank)) {
+         if ((lgid = pending_mdsmap.find_standby_for(i->second.rank, i->second.name))) {
+           MDSMap::mds_info_t& sinfo = i->second;
+           dout(20) << " mds" << i->second.rank
+                    << " standby gid " << lgid << " has state "
+                    << ceph_mds_state_name(sinfo.state)
+                    << dendl;
+           if (sinfo.state == MDSMap::STATE_STANDBY_REPLAY) {
+             dout(20) << "  skipping this MDS since it has a follower!" << dendl;
+             continue; // this MDS already has a standby
+           }
+         }
+         // hey, we found an MDS without a standby. Pair them!
+         info.standby_for_rank = i->second.rank;
+         dout(10) << "  setting to shadow mds rank " << info.standby_for_rank << dendl;
+         info.state = MDSMap::STATE_STANDBY_REPLAY;
+         do_propose = true;
+         break;
+       }
+      }
+    }
+  }
+
   if (do_propose)
     propose_pending();
 }