From a8fc92933bb24fe8ed06407335746f1262d6aea8 Mon Sep 17 00:00:00 2001 From: Patrick Donnelly Date: Fri, 25 Aug 2017 14:06:03 -0700 Subject: [PATCH] cephfs: obsolete deprecated mds commands Fixes: http://tracker.ceph.com/issues/20596 Signed-off-by: Patrick Donnelly --- src/mon/FSCommands.cc | 49 ------------ src/mon/MDSMonitor.cc | 169 +----------------------------------------- src/mon/MDSMonitor.h | 7 -- src/mon/MonCommands.h | 20 ++--- 4 files changed, 11 insertions(+), 234 deletions(-) diff --git a/src/mon/FSCommands.cc b/src/mon/FSCommands.cc index 1e4ead53726..49d4bf5cd9d 100644 --- a/src/mon/FSCommands.cc +++ b/src/mon/FSCommands.cc @@ -748,48 +748,6 @@ class RemoveDataPoolHandler : public FileSystemCommandHandler } }; - -/** - * For commands that refer to a particular filesystem, - * enable wrapping to implement the legacy version of - * the command (like "mds add_data_pool" vs "fs add_data_pool") - * - * The wrapped handler must expect a fs_name argument in - * its command map. - */ -template -class LegacyHandler : public T -{ - std::string legacy_prefix; - - public: - template - LegacyHandler(const std::string &new_prefix, Args&&... args) - : T(std::forward(args)...) - { - legacy_prefix = new_prefix; - } - - std::string const &get_prefix() override {return legacy_prefix;} - - int handle( - Monitor *mon, - FSMap &fsmap, - MonOpRequestRef op, - map &cmdmap, - std::stringstream &ss) override - { - auto fs = fsmap.get_legacy_filesystem(); - if (fs == nullptr) { - ss << "No filesystem configured"; - return -ENOENT; - } - std::map modified = cmdmap; - modified["fs_name"] = fs->mds_map.get_fs_name(); - return T::handle(mon, fsmap, op, modified, ss); - } -}; - /** * For commands with an alternative prefix */ @@ -825,16 +783,9 @@ FileSystemCommandHandler::load(Paxos *paxos) std::list > handlers; handlers.push_back(std::make_shared()); - handlers.push_back(std::make_shared >("mds set")); handlers.push_back(std::make_shared()); handlers.push_back(std::make_shared(paxos)); - handlers.push_back(std::make_shared >( - "mds add_data_pool", paxos)); handlers.push_back(std::make_shared()); - handlers.push_back(std::make_shared >( - "mds remove_data_pool")); - handlers.push_back(std::make_shared >( - "mds rm_data_pool")); handlers.push_back(std::make_shared(paxos)); 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 bae812a95da..545125c51b5 100644 --- a/src/mon/MDSMonitor.cc +++ b/src/mon/MDSMonitor.cc @@ -864,53 +864,6 @@ bool MDSMonitor::preprocess_command(MonOpRequestRef op) ds << fsmap; } r = 0; - } else if (prefix == "mds dump") { - int64_t epocharg; - epoch_t epoch; - - FSMap *p = &fsmap; - if (cmd_getval(g_ceph_context, cmdmap, "epoch", epocharg)) { - epoch = epocharg; - bufferlist b; - int err = get_version(epoch, b); - if (err == -ENOENT) { - p = 0; - r = -ENOENT; - } else { - assert(err == 0); - assert(b.length()); - p = new FSMap; - p->decode(b); - } - } - if (p) { - stringstream ds; - const MDSMap *mdsmap = nullptr; - MDSMap blank; - blank.epoch = fsmap.epoch; - if (fsmap.legacy_client_fscid != FS_CLUSTER_ID_NONE) { - mdsmap = &(fsmap.filesystems[fsmap.legacy_client_fscid]->mds_map); - } else { - mdsmap = ␣ - } - if (f != NULL) { - f->open_object_section("mdsmap"); - mdsmap->dump(f.get()); - f->close_section(); - f->flush(ds); - r = 0; - } else { - mdsmap->print(ds); - r = 0; - } - - rdata.append(ds); - ss << "dumped fsmap epoch " << p->get_epoch(); - - if (p != &fsmap) { - delete p; - } - } } else if (prefix == "fs dump") { int64_t epocharg; epoch_t epoch; @@ -1004,29 +957,6 @@ bool MDSMonitor::preprocess_command(MonOpRequestRef op) count_metadata(field, f.get()); f->flush(ds); r = 0; - } else if (prefix == "mds getmap") { - epoch_t e; - int64_t epocharg; - bufferlist b; - if (cmd_getval(g_ceph_context, cmdmap, "epoch", epocharg)) { - e = epocharg; - int err = get_version(e, b); - if (err == -ENOENT) { - r = -ENOENT; - } else { - assert(err == 0); - assert(b.length()); - FSMap mm; - mm.decode(b); - mm.encode(rdata, m->get_connection()->get_features()); - ss << "got fsmap epoch " << mm.get_epoch(); - r = 0; - } - } else { - fsmap.encode(rdata, m->get_connection()->get_features()); - ss << "got fsmap epoch " << fsmap.get_epoch(); - r = 0; - } } else if (prefix == "mds compat show") { if (f) { f->open_object_section("mds_compat"); @@ -1298,8 +1228,6 @@ bool MDSMonitor::prepare_command(MonOpRequestRef op) goto out; } - r = legacy_filesystem_command(op, prefix, cmdmap, ss); - if (r == -ENOSYS && ss.str().empty()) { ss << "unrecognized command"; } @@ -1359,9 +1287,7 @@ int MDSMonitor::filesystem_command( string whostr; cmd_getval(g_ceph_context, cmdmap, "who", whostr); - if (prefix == "mds stop" || - prefix == "mds deactivate") { - + if (prefix == "mds deactivate") { mds_role_t role; r = parse_role(whostr, &role, ss); if (r < 0 ) { @@ -1538,99 +1464,6 @@ int MDSMonitor::filesystem_command( return r; } -/** - * Helper to legacy_filesystem_command - */ -void MDSMonitor::modify_legacy_filesystem( - std::function )> fn) -{ - pending_fsmap.modify_filesystem( - pending_fsmap.legacy_client_fscid, - fn - ); -} - - - -/** - * Handle a command that affects the filesystem (i.e. a filesystem - * must exist for the command to act upon). - * - * @retval 0 Command was successfully handled and has side effects - * @retval -EAGAIN Messages has been requeued for retry - * @retval -ENOSYS Unknown command - * @retval < 0 An error has occurred; **ss** may have been set. - */ -int MDSMonitor::legacy_filesystem_command( - MonOpRequestRef op, - std::string const &prefix, - map &cmdmap, - std::stringstream &ss) -{ - dout(4) << __func__ << " prefix='" << prefix << "'" << dendl; - op->mark_mdsmon_event(__func__); - int r = 0; - string whostr; - cmd_getval(g_ceph_context, cmdmap, "who", whostr); - - assert (pending_fsmap.legacy_client_fscid != FS_CLUSTER_ID_NONE); - - if (prefix == "mds set_max_mds") { - // NOTE: deprecated by "fs set max_mds" - int64_t maxmds; - if (!cmd_getval(g_ceph_context, cmdmap, "maxmds", maxmds) || maxmds <= 0) { - return -EINVAL; - } - - const MDSMap& mdsmap = - pending_fsmap.filesystems.at(pending_fsmap.legacy_client_fscid)->mds_map; - - if (!mdsmap.allows_multimds() && - maxmds > mdsmap.get_max_mds() && - maxmds > 1) { - ss << "multi-MDS clusters are not enabled; set 'allow_multimds' to enable"; - return -EINVAL; - } - - if (maxmds > MAX_MDS) { - ss << "may not have more than " << MAX_MDS << " MDS ranks"; - return -EINVAL; - } - - modify_legacy_filesystem( - [maxmds](std::shared_ptr fs) - { - fs->mds_map.set_max_mds(maxmds); - }); - - r = 0; - ss << "max_mds = " << maxmds; - } else if (prefix == "mds cluster_down") { - // NOTE: deprecated by "fs set cluster_down" - modify_legacy_filesystem( - [](std::shared_ptr fs) - { - fs->mds_map.set_flag(CEPH_MDSMAP_DOWN); - }); - ss << "marked fsmap DOWN"; - r = 0; - } else if (prefix == "mds cluster_up") { - // NOTE: deprecated by "fs set cluster_up" - modify_legacy_filesystem( - [](std::shared_ptr fs) - { - fs->mds_map.clear_flag(CEPH_MDSMAP_DOWN); - }); - ss << "unmarked fsmap DOWN"; - r = 0; - } else { - return -ENOSYS; - } - - return r; -} - - void MDSMonitor::check_subs() { std::list types; diff --git a/src/mon/MDSMonitor.h b/src/mon/MDSMonitor.h index afaaa7e72ca..840f4e469a5 100644 --- a/src/mon/MDSMonitor.h +++ b/src/mon/MDSMonitor.h @@ -96,13 +96,6 @@ class MDSMonitor : public PaxosService { mds_role_t *role, std::ostream &ss); - void modify_legacy_filesystem( - std::function )> fn); - int legacy_filesystem_command( - MonOpRequestRef op, - std::string const &prefix, - map &cmdmap, - std::stringstream &ss); int filesystem_command( MonOpRequestRef op, std::string const &prefix, diff --git a/src/mon/MonCommands.h b/src/mon/MonCommands.h index d8f743f3416..0c29484b180 100644 --- a/src/mon/MonCommands.h +++ b/src/mon/MonCommands.h @@ -284,13 +284,13 @@ COMMAND("mds stat", "show MDS status", "mds", "r", "cli,rest") COMMAND_WITH_FLAG("mds dump " "name=epoch,type=CephInt,req=false,range=0", \ "dump legacy MDS cluster info, optionally from epoch", - "mds", "r", "cli,rest", FLAG(DEPRECATED)) + "mds", "r", "cli,rest", FLAG(OBSOLETE)) COMMAND("fs dump " "name=epoch,type=CephInt,req=false,range=0", \ "dump all CephFS status, optionally from epoch", "mds", "r", "cli,rest") COMMAND_WITH_FLAG("mds getmap " \ "name=epoch,type=CephInt,req=false,range=0", \ - "get MDS map, optionally from epoch", "mds", "r", "cli,rest", FLAG(DEPRECATED)) + "get MDS map, optionally from epoch", "mds", "r", "cli,rest", FLAG(OBSOLETE)) COMMAND("mds metadata name=who,type=CephString,req=false", "fetch metadata for mds ", "mds", "r", "cli,rest") @@ -307,19 +307,19 @@ COMMAND_WITH_FLAG("mds tell " \ COMMAND("mds compat show", "show mds compatibility settings", \ "mds", "r", "cli,rest") COMMAND_WITH_FLAG("mds stop name=who,type=CephString", "stop mds", \ - "mds", "rw", "cli,rest", FLAG(DEPRECATED)) + "mds", "rw", "cli,rest", FLAG(OBSOLETE)) COMMAND("mds deactivate name=who,type=CephString", "clean up specified MDS rank (use with `set max_mds` to shrink cluster)", \ "mds", "rw", "cli,rest") COMMAND_WITH_FLAG("mds set_max_mds " \ "name=maxmds,type=CephInt,range=0", \ - "set max MDS index", "mds", "rw", "cli,rest", FLAG(DEPRECATED)) + "set max MDS index", "mds", "rw", "cli,rest", FLAG(OBSOLETE)) COMMAND_WITH_FLAG("mds set " \ "name=var,type=CephChoices,strings=max_mds|max_file_size" "|allow_new_snaps|inline_data|allow_multimds|allow_dirfrags " \ "name=val,type=CephString " \ "name=confirm,type=CephString,req=false", \ - "set mds parameter to ", "mds", "rw", "cli,rest", FLAG(DEPRECATED)) + "set mds parameter to ", "mds", "rw", "cli,rest", FLAG(OBSOLETE)) // arbitrary limit 0-20 below; worth standing on head to make it // relate to actual state definitions? // #include "include/ceph_fs.h" @@ -337,8 +337,8 @@ COMMAND("mds rm " \ "remove nonactive mds", "mds", "rw", "cli,rest") COMMAND("mds rmfailed name=who,type=CephString name=confirm,type=CephString,req=false", \ "remove failed mds", "mds", "rw", "cli,rest") -COMMAND_WITH_FLAG("mds cluster_down", "take MDS cluster down", "mds", "rw", "cli,rest", FLAG(DEPRECATED)) -COMMAND_WITH_FLAG("mds cluster_up", "bring MDS cluster up", "mds", "rw", "cli,rest", FLAG(DEPRECATED)) +COMMAND_WITH_FLAG("mds cluster_down", "take MDS cluster down", "mds", "rw", "cli,rest", FLAG(OBSOLETE)) +COMMAND_WITH_FLAG("mds cluster_up", "bring MDS cluster up", "mds", "rw", "cli,rest", FLAG(OBSOLETE)) COMMAND("mds compat rm_compat " \ "name=feature,type=CephInt,range=0", \ "remove compatible feature", "mds", "rw", "cli,rest") @@ -347,13 +347,13 @@ COMMAND("mds compat rm_incompat " \ "remove incompatible feature", "mds", "rw", "cli,rest") COMMAND_WITH_FLAG("mds add_data_pool " \ "name=pool,type=CephString", \ - "add data pool ", "mds", "rw", "cli,rest", FLAG(DEPRECATED)) + "add data pool ", "mds", "rw", "cli,rest", FLAG(OBSOLETE)) COMMAND_WITH_FLAG("mds remove_data_pool " \ "name=pool,type=CephString", \ - "remove data pool ", "mds", "rw", "cli,rest", FLAG(DEPRECATED)) + "remove data pool ", "mds", "rw", "cli,rest", FLAG(OBSOLETE)) COMMAND_WITH_FLAG("mds rm_data_pool " \ "name=pool,type=CephString", \ - "remove data pool ", "mds", "rw", "cli,rest", FLAG(DEPRECATED)) + "remove data pool ", "mds", "rw", "cli,rest", FLAG(OBSOLETE)) COMMAND_WITH_FLAG("mds newfs " \ "name=metadata,type=CephInt,range=0 " \ "name=data,type=CephInt,range=0 " \ -- 2.39.5