return enable_multiple;
}
+ void set_legacy_client_fscid(fs_cluster_id_t fscid)
+ {
+ assert(fscid == FS_CLUSTER_ID_NONE || filesystems.count(fscid));
+ legacy_client_fscid = fscid;
+ }
+
/**
* Get state of all daemons (for all filesystems, including all standbys)
*/
}
};
+class SetDefaultHandler : public FileSystemCommandHandler
+{
+ public:
+ SetDefaultHandler()
+ : FileSystemCommandHandler("fs set-default")
+ {}
+
+ int handle(
+ Monitor *mon,
+ FSMap &fsmap,
+ MonOpRequestRef op,
+ map<string, cmd_vartype> &cmdmap,
+ std::stringstream &ss) override
+ {
+ std::string fs_name;
+ cmd_getval(g_ceph_context, cmdmap, "fs_name", fs_name);
+ auto fs = fsmap.get_filesystem(fs_name);
+ if (fs == nullptr) {
+ ss << "filesystem '" << fs_name << "' does not exist";
+ return -ENOENT;
+ }
+
+ fsmap.set_legacy_client_fscid(fs->fscid);
+ return 0;
+ }
+};
class RemoveDataPoolHandler : public FileSystemCommandHandler
{
}
};
+/**
+ * For commands with an alternative prefix
+ */
+template<typename T>
+class AliasHandler : public T
+{
+ std::string alias_prefix;
+
+ public:
+ AliasHandler(const std::string &new_prefix)
+ : T()
+ {
+ alias_prefix = new_prefix;
+ }
+
+ std::string const &get_prefix() override {return alias_prefix;}
+
+ int handle(
+ Monitor *mon,
+ FSMap &fsmap,
+ MonOpRequestRef op,
+ map<string, cmd_vartype> &cmdmap,
+ std::stringstream &ss) override
+ {
+ return T::handle(mon, fsmap, op, cmdmap, ss);
+ }
+};
+
std::list<std::shared_ptr<FileSystemCommandHandler> > FileSystemCommandHandler::load()
{
"mds rm_data_pool"));
handlers.push_back(std::make_shared<FsNewHandler>());
+ handlers.push_back(std::make_shared<SetDefaultHandler>());
+ handlers.push_back(std::make_shared<AliasHandler<SetDefaultHandler> >(
+ "fs set_default"));
+
return handlers;
}
}
}
+ if (prefix == "mds newfs") {
+ // newfs is the legacy command that in single-filesystem times
+ // used to be equivalent to doing an "fs rm ; fs new". We
+ // can't do this in a sane way in multi-filesystem world.
+ ss << "'newfs' no longer available. Please use 'fs new'.";
+ r = -EINVAL;
+ goto out;
+ }
+
/* Execute filesystem add/remove, or pass through to filesystem_command */
r = management_command(op, prefix, cmdmap, ss);
if (r >= 0)
map<string, cmd_vartype> &cmdmap,
std::stringstream &ss)
{
- op->mark_mdsmon_event(__func__);
-
- if (prefix == "mds newfs") {
- // newfs is the legacy command that in single-filesystem times
- // used to be equivalent to doing an "fs rm ; fs new". We
- // can't do this in a sane way in multi-filesystem world.
- ss << "'newfs' no longer available. Please use 'fs new'.";
- return -EINVAL;
- } else if (prefix == "fs rm") {
+ 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)
// Persist the new FSMap
pending_fsmap.filesystems[new_fs->fscid] = new_fs;
return 0;
- } else if (prefix == "fs set_default" ||
- prefix == "fs set-default") {
- string fs_name;
- cmd_getval(g_ceph_context, cmdmap, "fs_name", fs_name);
- auto fs = pending_fsmap.get_filesystem(fs_name);
- if (fs == nullptr) {
- ss << "filesystem '" << fs_name << "' does not exist";
- return -ENOENT;
- }
-
- pending_fsmap.legacy_client_fscid = fs->fscid;
- return 0;
} else {
return -ENOSYS;
}