From: Yan, Zheng Date: Wed, 29 Mar 2017 08:35:15 +0000 (+0800) Subject: mon/MDSMonitor: only allow deactivating the mds with max rank X-Git-Tag: v12.1.0~10^2~28^2~17 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=2c08f58ee8353322a342ce043150aafc8dd9c381;p=ceph.git mon/MDSMonitor: only allow deactivating the mds with max rank Signed-off-by: "Yan, Zheng" --- diff --git a/src/mds/MDSMap.h b/src/mds/MDSMap.h index 1d8e29b2a36b..b7818437c29e 100644 --- a/src/mds/MDSMap.h +++ b/src/mds/MDSMap.h @@ -346,6 +346,10 @@ public: unsigned get_num_up_mds() const { return up.size(); } + mds_rank_t get_last_in_mds() const { + auto p = in.rbegin(); + return p == in.rend() ? MDS_RANK_NONE : *p; + } int get_num_failed_mds() const { return failed.size(); } diff --git a/src/mon/MDSMonitor.cc b/src/mon/MDSMonitor.cc index 16e455295252..6a3b03437eb8 100644 --- a/src/mon/MDSMonitor.cc +++ b/src/mon/MDSMonitor.cc @@ -1328,6 +1328,10 @@ int MDSMonitor::filesystem_command( ss << "can't tell the root (" << fs->mds_map.get_root() << ") or tableserver (" << fs->mds_map.get_tableserver() << ") to deactivate"; + } else if (role.rank != fs->mds_map.get_last_in_mds()) { + r = -EINVAL; + ss << "mds." << role << " doesn't have the max rank (" + << fs->mds_map.get_last_in_mds() << ")"; } else if (fs->mds_map.get_num_in_mds() <= size_t(fs->mds_map.get_max_mds())) { r = -EBUSY; ss << "must decrease max_mds or else MDS will immediately reactivate";