From: John Spray Date: Tue, 21 Feb 2017 15:50:32 +0000 (+0000) Subject: mon: split "fs rm" into command handler X-Git-Tag: v12.0.1~238^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=d0884ab5e78905f64400dfa4b564119e39b77d72;p=ceph.git mon: split "fs rm" into command handler Signed-off-by: John Spray &cmdmap, + std::stringstream &ss) override + { + // Check caller has correctly named the FS to delete + // (redundant while there is only one FS, but command + // syntax should apply to multi-FS future) + string fs_name; + cmd_getval(g_ceph_context, cmdmap, "fs_name", fs_name); + auto fs = fsmap.get_filesystem(fs_name); + if (fs == nullptr) { + // Consider absence success to make deletes idempotent + ss << "filesystem '" << fs_name << "' does not exist"; + return 0; + } + + // Check that no MDS daemons are active + if (fs->mds_map.get_num_up_mds() > 0) { + ss << "all MDS daemons must be inactive before removing filesystem"; + return -EINVAL; + } + + // Check for confirmation flag + string sure; + cmd_getval(g_ceph_context, cmdmap, "sure", sure); + if (sure != "--yes-i-really-mean-it") { + ss << "this is a DESTRUCTIVE operation and will make data in your filesystem permanently" \ + " inaccessible. Add --yes-i-really-mean-it if you are sure you wish to continue."; + return -EPERM; + } + + if (fsmap.get_legacy_client_fscid() == fs->fscid) { + fsmap.set_legacy_client_fscid(FS_CLUSTER_ID_NONE); + } + + // There may be standby_replay daemons left here + for (const auto &i : fs->mds_map.get_mds_info()) { + assert(i.second.state == MDSMap::STATE_STANDBY_REPLAY); + + // Standby replays don't write, so it isn't important to + // wait for an osdmap propose here: ignore return value. + mon->mdsmon()->fail_mds_gid(i.first); + } + + fsmap.erase_filesystem(fs->fscid); + + return 0; + } +}; + class RemoveDataPoolHandler : public FileSystemCommandHandler { public: @@ -662,6 +723,7 @@ std::list > FileSystemCommandHandler:: handlers.push_back(std::make_shared >( "mds rm_data_pool")); handlers.push_back(std::make_shared()); + handlers.push_back(std::make_shared()); handlers.push_back(std::make_shared()); handlers.push_back(std::make_shared >( diff --git a/src/mon/MDSMonitor.cc b/src/mon/MDSMonitor.cc index 07ed67d5cdf..c4d5ca978f7 100644 --- a/src/mon/MDSMonitor.cc +++ b/src/mon/MDSMonitor.cc @@ -1317,48 +1317,7 @@ int MDSMonitor::management_command( map &cmdmap, std::stringstream &ss) { - if (prefix == "fs rm") { - // Check caller has correctly named the FS to delete - // (redundant while there is only one FS, but command - // syntax should apply to multi-FS future) - string fs_name; - cmd_getval(g_ceph_context, cmdmap, "fs_name", fs_name); - auto fs = pending_fsmap.get_filesystem(fs_name); - if (fs == nullptr) { - // Consider absence success to make deletes idempotent - ss << "filesystem '" << fs_name << "' does not exist"; - return 0; - } - - // Check that no MDS daemons are active - if (!fs->mds_map.up.empty()) { - ss << "all MDS daemons must be inactive before removing filesystem"; - return -EINVAL; - } - - // Check for confirmation flag - string sure; - cmd_getval(g_ceph_context, cmdmap, "sure", sure); - if (sure != "--yes-i-really-mean-it") { - ss << "this is a DESTRUCTIVE operation and will make data in your filesystem permanently" \ - " inaccessible. Add --yes-i-really-mean-it if you are sure you wish to continue."; - return -EPERM; - } - - if (pending_fsmap.legacy_client_fscid == fs->fscid) { - pending_fsmap.legacy_client_fscid = FS_CLUSTER_ID_NONE; - } - - // There may be standby_replay daemons left here - for (const auto &i : fs->mds_map.mds_info) { - assert(i.second.state == MDSMap::STATE_STANDBY_REPLAY); - fail_mds_gid(i.first); - } - - pending_fsmap.filesystems.erase(fs->fscid); - - return 0; - } else if (prefix == "fs reset") { + if (prefix == "fs reset") { string fs_name; cmd_getval(g_ceph_context, cmdmap, "fs_name", fs_name); auto fs = pending_fsmap.get_filesystem(fs_name); diff --git a/src/mon/MDSMonitor.h b/src/mon/MDSMonitor.h index bf88c69f086..23a3431a4d6 100644 --- a/src/mon/MDSMonitor.h +++ b/src/mon/MDSMonitor.h @@ -65,6 +65,10 @@ class MDSMonitor : public PaxosService { void dump_info(Formatter *f); int print_nodes(Formatter *f); + /** + * Return true if a blacklist was done (i.e. OSD propose needed) + */ + bool fail_mds_gid(mds_gid_t gid); protected: // mds maps FSMap fsmap; // current @@ -88,10 +92,6 @@ class MDSMonitor : public PaxosService { list > *detail, CephContext *cct) const override; int fail_mds(std::ostream &ss, const std::string &arg); - /** - * Return true if a blacklist was done (i.e. OSD propose needed) - */ - bool fail_mds_gid(mds_gid_t gid); bool preprocess_command(MonOpRequestRef op); bool prepare_command(MonOpRequestRef op);