From 2c08f58ee8353322a342ce043150aafc8dd9c381 Mon Sep 17 00:00:00 2001 From: "Yan, Zheng" Date: Wed, 29 Mar 2017 16:35:15 +0800 Subject: [PATCH] mon/MDSMonitor: only allow deactivating the mds with max rank Signed-off-by: "Yan, Zheng" --- src/mds/MDSMap.h | 4 ++++ src/mon/MDSMonitor.cc | 4 ++++ 2 files changed, 8 insertions(+) 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"; -- 2.47.3