From 5e27a079e8cfb4c90de1d36bfef0065d9a5cbb14 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Tue, 12 Apr 2011 14:13:56 -0700 Subject: [PATCH] mon: simplify mds follow checks 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 --- src/mon/MDSMonitor.cc | 77 +++++++++++++++++++++++++------------------ 1 file changed, 45 insertions(+), 32 deletions(-) diff --git a/src/mon/MDSMonitor.cc b/src/mon/MDSMonitor.cc index 36cf8a02d3fc6..96508f9971037 100644 --- a/src/mon/MDSMonitor.cc +++ b/src/mon/MDSMonitor.cc @@ -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::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::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::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(); } -- 2.39.5