++j) {
MDSMap::mds_info_t& info = j->second;
- if (info.state != MDSMap::STATE_STANDBY ||
- info.standby_for_rank != MDSMap::MDS_STANDBY_ANY)
+ if (info.state != MDSMap::STATE_STANDBY)
continue;
/*
*/
dout(20) << "gid " << j->first << " is standby and following nobody" << dendl;
- uint64_t lgid = 0;
+ // standby for someone specific?
+ if (info.standby_for_rank >= 0) {
+ if (pending_mdsmap.is_followable(info.standby_for_rank) &&
+ try_standby_replay(info, pending_mdsmap.mds_info[pending_mdsmap.up[info.standby_for_rank]]))
+ do_propose = true;
+ continue;
+ }
+
+ // check everyone
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
- }
+ if (info.standby_for_name.length() &&
+ info.standby_for_name != i->second.name)
+ continue; // we're supposed to follow someone else
+
+ if (try_standby_replay(info, i->second)) {
+ do_propose = true;
+ break;
}
- // 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;
}
}
}
propose_pending();
}
+bool MDSMonitor::try_standby_replay(MDSMap::mds_info_t& finfo, MDSMap::mds_info_t& ainfo)
+{
+ // someone else already following?
+ uint64_t lgid = pending_mdsmap.find_standby_for(ainfo.rank, ainfo.name);
+ if (lgid) {
+ MDSMap::mds_info_t& sinfo = pending_mdsmap.mds_info[lgid];
+ dout(20) << " mds" << ainfo.rank
+ << " standby gid " << lgid << " with 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;
+ return false; // this MDS already has a standby
+ }
+ }
+
+ // hey, we found an MDS without a standby. Pair them!
+ finfo.standby_for_rank = ainfo.rank;
+ dout(10) << " setting to shadow mds rank " << finfo.standby_for_rank << dendl;
+ finfo.state = MDSMap::STATE_STANDBY_REPLAY;
+ return true;
+}
+
void MDSMonitor::do_stop()
{