<< " <output>: [summary|list|binary|json] [--path <path>]\n"
<< "\n"
<< "General options:\n"
- << " --rank=filesystem:mds-rank Journal rank (required if multiple\n"
- << " file systems, default is rank 0 on\n"
- << " the only filesystem otherwise.)\n"
+ << " --rank=filesystem:mds-rank|all Journal rank (mandatory)\n"
<< " --journal=<mdlog|purge_queue> Journal type (purge_queue means\n"
<< " this journal is used to queue for purge operation,\n"
<< " default is mdlog, and only mdlog support event mode)\n"
std::string rank_str;
if (!ceph_argparse_witharg(argv, arg, &rank_str, "--rank", (char*)NULL)) {
- // Default: act on rank 0. Will give the user an error if they
- // try invoking this way when they have more than one filesystem.
- rank_str = "0";
+ derr << "missing mandatory \"--rank\" argument" << dendl;
+ return -EINVAL;
}
if (!ceph_argparse_witharg(argv, arg, &type, "--journal", (char*)NULL)) {
return r;
}
- r = role_selector.parse(*fsmap, rank_str);
+ r = role_selector.parse(*fsmap, rank_str, false);
if (r != 0) {
derr << "Couldn't determine MDS rank." << dendl;
return r;
// =========
// journal and header are general journal mode
// event mode is only specific for mdlog
- for (auto role : role_selector.get_roles()) {
+ auto roles = role_selector.get_roles();
+ if (roles.size() > 1) {
+ const std::string &command = argv[0];
+ bool allowed = can_execute_for_all_ranks(mode, command);
+ if (!allowed) {
+ derr << "operation not allowed for all ranks" << dendl;
+ return -EINVAL;
+ }
+
+ all_ranks = true;
+ }
+ for (auto role : roles) {
rank = role.rank;
std::vector<const char *> rank_argv(argv);
dout(4) << "Executing for rank " << rank << dendl;
return prefix + "." + std::to_string(rank);
}
+bool JournalTool::can_execute_for_all_ranks(const std::string &mode,
+ const std::string &command) {
+ if (mode == "journal" && command == "import") {
+ return false;
+ }
+
+ return true;
+}
+
/**
* Handle arguments for 'journal' mode
*
}
}
-int MDSRoleSelector::parse(const FSMap &fsmap, std::string const &str)
+int MDSRoleSelector::parse(const FSMap &fsmap, std::string const &str,
+ bool allow_unqualified_rank)
{
auto colon_pos = str.find(":");
if (colon_pos == std::string::npos) {
// An unqualified rank. Only valid if there is only one
// namespace.
- if (fsmap.filesystem_count() == 1) {
+ if (fsmap.filesystem_count() == 1 && allow_unqualified_rank) {
fscid = fsmap.get_filesystem()->fscid;
return parse_rank(fsmap, str);
} else {