}
};
-
-/**
- * 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<typename T>
-class LegacyHandler : public T
-{
- std::string legacy_prefix;
-
- public:
- template <typename... Args>
- LegacyHandler(const std::string &new_prefix, Args&&... args)
- : T(std::forward<Args>(args)...)
- {
- legacy_prefix = new_prefix;
- }
-
- std::string const &get_prefix() override {return legacy_prefix;}
-
- int handle(
- Monitor *mon,
- FSMap &fsmap,
- MonOpRequestRef op,
- map<string, cmd_vartype> &cmdmap,
- std::stringstream &ss) override
- {
- auto fs = fsmap.get_legacy_filesystem();
- if (fs == nullptr) {
- ss << "No filesystem configured";
- return -ENOENT;
- }
- std::map<string, cmd_vartype> 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
*/
std::list<std::shared_ptr<FileSystemCommandHandler> > handlers;
handlers.push_back(std::make_shared<SetHandler>());
- handlers.push_back(std::make_shared<LegacyHandler<SetHandler> >("mds set"));
handlers.push_back(std::make_shared<FlagSetHandler>());
handlers.push_back(std::make_shared<AddDataPoolHandler>(paxos));
- handlers.push_back(std::make_shared<LegacyHandler<AddDataPoolHandler> >(
- "mds add_data_pool", paxos));
handlers.push_back(std::make_shared<RemoveDataPoolHandler>());
- handlers.push_back(std::make_shared<LegacyHandler<RemoveDataPoolHandler> >(
- "mds remove_data_pool"));
- handlers.push_back(std::make_shared<LegacyHandler<RemoveDataPoolHandler> >(
- "mds rm_data_pool"));
handlers.push_back(std::make_shared<FsNewHandler>(paxos));
handlers.push_back(std::make_shared<RemoveFilesystemHandler>());
handlers.push_back(std::make_shared<ResetFilesystemHandler>());
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;
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");
goto out;
}
- r = legacy_filesystem_command(op, prefix, cmdmap, ss);
-
if (r == -ENOSYS && ss.str().empty()) {
ss << "unrecognized 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 ) {
return r;
}
-/**
- * Helper to legacy_filesystem_command
- */
-void MDSMonitor::modify_legacy_filesystem(
- std::function<void(std::shared_ptr<Filesystem> )> 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<string, cmd_vartype> &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<Filesystem> 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<Filesystem> 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<Filesystem> 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<std::string> types;
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 <who>",
"mds", "r", "cli,rest")
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 <var> to <val>", "mds", "rw", "cli,rest", FLAG(DEPRECATED))
+ "set mds parameter <var> to <val>", "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"
"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")
"remove incompatible feature", "mds", "rw", "cli,rest")
COMMAND_WITH_FLAG("mds add_data_pool " \
"name=pool,type=CephString", \
- "add data pool <pool>", "mds", "rw", "cli,rest", FLAG(DEPRECATED))
+ "add data pool <pool>", "mds", "rw", "cli,rest", FLAG(OBSOLETE))
COMMAND_WITH_FLAG("mds remove_data_pool " \
"name=pool,type=CephString", \
- "remove data pool <pool>", "mds", "rw", "cli,rest", FLAG(DEPRECATED))
+ "remove data pool <pool>", "mds", "rw", "cli,rest", FLAG(OBSOLETE))
COMMAND_WITH_FLAG("mds rm_data_pool " \
"name=pool,type=CephString", \
- "remove data pool <pool>", "mds", "rw", "cli,rest", FLAG(DEPRECATED))
+ "remove data pool <pool>", "mds", "rw", "cli,rest", FLAG(OBSOLETE))
COMMAND_WITH_FLAG("mds newfs " \
"name=metadata,type=CephInt,range=0 " \
"name=data,type=CephInt,range=0 " \