]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/MDSMonitor: only allow deactivating the mds with max rank
authorYan, Zheng <zyan@redhat.com>
Wed, 29 Mar 2017 08:35:15 +0000 (16:35 +0800)
committerYan, Zheng <zyan@redhat.com>
Thu, 11 May 2017 06:13:23 +0000 (14:13 +0800)
Signed-off-by: "Yan, Zheng" <zyan@redhat.com>
src/mds/MDSMap.h
src/mon/MDSMonitor.cc

index 1d8e29b2a36be76474a1e21f4ee9660cfcd540fc..b7818437c29ea630545eddb73fe640e7a54a7288 100644 (file)
@@ -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();
   }
index 16e4552952525e2aa1192f538687b81190e1b12b..6a3b03437eb8b41a61d494e204309f952d33f376 100644 (file)
@@ -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";