From cc207ca54c2b297eabd561cc769be0ed3f5f6989 Mon Sep 17 00:00:00 2001 From: Greg Farnum Date: Thu, 20 Jan 2011 11:57:23 -0800 Subject: [PATCH] MDSMonitor: Adjust handling of MDSes asking for standby-replay. 1) If the MDS does not specify an MDS to follow, we mark them as standing-by for -2. MDSMap::find_standby_for() has been modified to grab these MDSes. 2) If an MDS asks for standby-replay and specifies a name but not a rank, fill in the rank if the named MDS is known to us. If it is not known, do nothing. Signed-off-by: Greg Farnum --- src/mds/MDSMap.h | 18 +++++++++++++----- src/mon/MDSMonitor.cc | 24 +++++++++++++++++++++++- 2 files changed, 36 insertions(+), 6 deletions(-) diff --git a/src/mds/MDSMap.h b/src/mds/MDSMap.h index 13e8f7dbbecc1..90a656e49fc92 100644 --- a/src/mds/MDSMap.h +++ b/src/mds/MDSMap.h @@ -304,18 +304,26 @@ public: } uint64_t find_standby_for(int mds, string& name) { + map::const_iterator generic_standby + = mds_info.end(); for (map::const_iterator p = mds_info.begin(); p != mds_info.end(); ++p) { - if (p->second.rank == -1 && - (p->second.standby_for_rank == mds || - p->second.standby_for_name == name) && + if (((p->second.rank == -1 && + (p->second.standby_for_rank == mds || + p->second.standby_for_name == name)) || + (p->second.standby_for_rank == -2)) && (p->second.state == MDSMap::STATE_STANDBY || p->second.state == MDSMap::STATE_STANDBY_REPLAY) && - !p->second.laggy()) { - return p->first; + !p->second.laggy()) { + if (p->second.standby_for_rank == -2) + generic_standby = p; + else + return p->first; } } + if (generic_standby != mds_info.end()) + return generic_standby->first; for (map::const_iterator p = mds_info.begin(); p != mds_info.end(); ++p) { diff --git a/src/mon/MDSMonitor.cc b/src/mon/MDSMonitor.cc index 589e5d6a57f59..a1d7d73e28bad 100644 --- a/src/mon/MDSMonitor.cc +++ b/src/mon/MDSMonitor.cc @@ -238,7 +238,8 @@ bool MDSMonitor::preprocess_beacon(MMDSBeacon *m) (state == MDSMap::STATE_STANDBY_REPLAY || state == MDSMap::STATE_ONESHOT_REPLAY) && (pending_mdsmap.is_degraded() || - pending_mdsmap.get_state(m->get_standby_for_rank()) < MDSMap::STATE_ACTIVE)) { + ((m->get_standby_for_rank() != -1) && + pending_mdsmap.get_state(m->get_standby_for_rank()) < MDSMap::STATE_ACTIVE))) { dout(10) << "mds_beacon can't standby-replay mds" << m->get_standby_for_rank() << " at this time (cluster degraded, or mds not active)" << dendl; dout(10) << "pending_mdsmap.is_degraded()==" << pending_mdsmap.is_degraded() << " rank state: " << ceph_mds_state_name(pending_mdsmap.get_state(m->get_standby_for_rank())) << dendl; @@ -360,6 +361,7 @@ bool MDSMonitor::prepare_beacon(MMDSBeacon *m) dout(10) << "prepare_beacon mds" << info.rank << " " << ceph_mds_state_name(info.state) << " -> " << ceph_mds_state_name(state) + << " standby_for_rank=" << m->get_standby_for_rank() << dendl; if (state == MDSMap::STATE_STOPPED) { pending_mdsmap.up.erase(info.rank); @@ -367,6 +369,26 @@ bool MDSMonitor::prepare_beacon(MMDSBeacon *m) pending_mdsmap.stopped.insert(info.rank); pending_mdsmap.mds_info.erase(gid); // last! info is a ref into this map last_beacon.erase(gid); + } else if (state == MDSMap::STATE_STANDBY_REPLAY && + (m->get_standby_for_rank() == -1) && + (m->get_standby_for_name().empty())) { + // note the MDS as available for standby_replay on any MDS + dout(10) << "marking available for standby_replay" << dendl; + info.standby_for_rank = -2; + } else if (state == MDSMap::STATE_STANDBY_REPLAY && + m->get_standby_for_rank() == -1) { + /* convert name to rank. If we don't have it, do nothing. The + mds will stay in standby and keep requesting the state change */ + dout(20) << "looking for mds " << m->get_standby_for_name() + << " to STANDBY_REPLAY for" << dendl; + if (pending_mdsmap.find_by_name(m->get_standby_for_name())) { + info.standby_for_rank = + pending_mdsmap.find_by_name(m->get_standby_for_name())->rank; + dout(10) <<" found mds " << m->get_standby_for_name() + << "; it has rank " << info.standby_for_rank << dendl; + info.state = MDSMap::STATE_STANDBY_REPLAY; + info.state_seq = seq; + } } else { info.state = state; info.state_seq = seq; -- 2.39.5