From 7e21f9511269b3861f0f90454299e9ab51905139 Mon Sep 17 00:00:00 2001 From: Milind Changire Date: Mon, 30 Mar 2020 11:21:27 +0530 Subject: [PATCH] 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 (cherry picked from commit d9f62d3a1de68eb44b9fc9a40ca36c70c5c772a4) --- src/tools/cephfs/JournalTool.cc | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/tools/cephfs/JournalTool.cc b/src/tools/cephfs/JournalTool.cc index 3a3816c7a8e9b..f6d7c4116354c 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 */ -- 2.39.5