From 24cabcfbeaaec2b45072ffbb7f4b4f16a375f38a Mon Sep 17 00:00:00 2001 From: John Spray Date: Mon, 22 May 2017 17:11:53 -0400 Subject: [PATCH] mon: fix accesing pending_fsmap from peon Fixes: http://tracker.ceph.com/issues/20040 Signed-off-by: John Spray --- src/mon/MDSMonitor.cc | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/mon/MDSMonitor.cc b/src/mon/MDSMonitor.cc index 92a3215e6cb7..4d5d67752600 100644 --- a/src/mon/MDSMonitor.cc +++ b/src/mon/MDSMonitor.cc @@ -1120,13 +1120,15 @@ bool MDSMonitor::fail_mds_gid(mds_gid_t gid) mds_gid_t MDSMonitor::gid_from_arg(const std::string& arg, std::ostream &ss) { + const FSMap *relevant_fsmap = mon->is_leader() ? &pending_fsmap : &fsmap; + // Try parsing as a role mds_role_t role; std::ostringstream ignore_err; // Don't spam 'ss' with parse_role errors int r = parse_role(arg, &role, ignore_err); if (r == 0) { // See if a GID is assigned to this role - auto fs = pending_fsmap.get_filesystem(role.fscid); + auto fs = relevant_fsmap->get_filesystem(role.fscid); assert(fs != nullptr); // parse_role ensures it exists if (fs->mds_map.is_up(role.rank)) { dout(10) << __func__ << ": validated rank/GID " << role @@ -1140,7 +1142,7 @@ mds_gid_t MDSMonitor::gid_from_arg(const std::string& arg, std::ostream &ss) unsigned long long maybe_gid = strict_strtoll(arg.c_str(), 10, &err); if (!err.empty()) { // Not a role or a GID, try as a daemon name - const MDSMap::mds_info_t *mds_info = fsmap.find_by_name(arg); + const MDSMap::mds_info_t *mds_info = relevant_fsmap->find_by_name(arg); if (!mds_info) { ss << "MDS named '" << arg << "' does not exist, or is not up"; @@ -1153,14 +1155,9 @@ mds_gid_t MDSMonitor::gid_from_arg(const std::string& arg, std::ostream &ss) // Not a role, but parses as a an integer, might be a GID dout(10) << __func__ << ": treating MDS reference '" << arg << "' as an integer " << maybe_gid << dendl; - if (mon->is_leader()) { - if (pending_fsmap.gid_exists(mds_gid_t(maybe_gid))) { - return mds_gid_t(maybe_gid); - } - } else { - if (fsmap.gid_exists(mds_gid_t(maybe_gid))) { - return mds_gid_t(maybe_gid); - } + + if (relevant_fsmap->gid_exists(mds_gid_t(maybe_gid))) { + return mds_gid_t(maybe_gid); } } -- 2.47.3