From: Milind Changire Date: Mon, 30 Mar 2020 05:51:27 +0000 (+0530) Subject: cephfs-journal-tool: correctly parse --dry_run argument X-Git-Tag: v16.1.0~2572^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=d9f62d3a1de68eb44b9fc9a40ca36c70c5c772a4;p=ceph.git cephfs-journal-tool: correctly parse --dry_run argument Correctly parse --dry_run argument and make it available to the "recover_dentries" command. Fixes: https://tracker.ceph.com/issues/44172 Signed-off-by: Milind Changire --- diff --git a/src/tools/cephfs/JournalTool.cc b/src/tools/cephfs/JournalTool.cc index 3a3816c7a8e9..f6d7c4116354 100644 --- a/src/tools/cephfs/JournalTool.cc +++ b/src/tools/cephfs/JournalTool.cc @@ -378,15 +378,23 @@ int JournalTool::main_event(std::vector &argv) } std::vector::iterator arg = argv.begin(); + bool dry_run = false; + std::string command = *(arg++); if (command != "get" && command != "splice" && command != "recover_dentries") { derr << "Unknown argument '" << command << "'" << dendl; return -EINVAL; } - if (command == "recover_dentries" && type != "mdlog") { - derr << "journaler for " << type << " can't do \"recover_dentries\"." << dendl; - return -EINVAL; + if (command == "recover_dentries") { + if (type != "mdlog") { + derr << "journaler for " << type << " can't do \"recover_dentries\"." << dendl; + return -EINVAL; + } else { + if (arg != argv.end() && ceph_argparse_flag(argv, arg, "--dry_run", (char*)NULL)) { + dry_run = true; + } + } } if (arg == argv.end()) { @@ -450,11 +458,6 @@ int JournalTool::main_event(std::vector &argv) return r; } - bool dry_run = false; - if (arg != argv.end() && ceph_argparse_flag(argv, arg, "--dry_run", (char*)NULL)) { - dry_run = true; - } - /** * Iterate over log entries, attempting to scavenge from each one */