From: Venky Shankar Date: Mon, 23 Jul 2018 06:28:07 +0000 (-0400) Subject: cephfs-journal-tool: dump to per rank output file wherever necessary X-Git-Tag: v14.0.1~193^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=cb19db75c7f23278d2598b58526d1bf8bf00b679;p=ceph.git cephfs-journal-tool: dump to per rank output file wherever necessary cephfs-journal-tool supports operations on all ranks. Operations such as dump/export do not write to distinct filenames hence overwriting the data dumped or exported for the previous rank. With this change (and further commits), for operations on all ranks, dump/export would write to distinct filenames suffixed by the mds rank (.0, .1, etc..). For operations on a single rank or if there exist a single rank, the passed in filename is used as it is. Signed-off-by: Venky Shankar --- diff --git a/src/tools/cephfs/JournalTool.cc b/src/tools/cephfs/JournalTool.cc index 227b334f8eb4..0ad770a95eb2 100644 --- a/src/tools/cephfs/JournalTool.cc +++ b/src/tools/cephfs/JournalTool.cc @@ -191,6 +191,14 @@ int JournalTool::validate_type(const std::string &type) return -1; } +std::string JournalTool::gen_dump_file_path(const std::string &prefix) { + if (!all_ranks) { + return prefix; + } + + return prefix + "." + std::to_string(rank); +} + /** * Handle arguments for 'journal' mode * @@ -397,6 +405,8 @@ int JournalTool::main_event(std::vector &argv) } } + const std::string dump_path = gen_dump_file_path(output_path); + // Execute command // =============== JournalScanner js(input, rank, type, filter); @@ -513,7 +523,7 @@ int JournalTool::main_event(std::vector &argv) // Generate output // =============== - EventOutput output(js, output_path); + EventOutput output(js, dump_path); int output_result = 0; if (output_style == "binary") { output_result = output.binary(); @@ -600,7 +610,8 @@ int JournalTool::journal_export(std::string const &path, bool import, bool force if (import) { r = dumper.undump(path.c_str(), force); } else { - r = dumper.dump(path.c_str()); + const std::string ex_path = gen_dump_file_path(path); + r = dumper.dump(ex_path.c_str()); } } diff --git a/src/tools/cephfs/JournalTool.h b/src/tools/cephfs/JournalTool.h index 87f37691ae22..081e140e8f21 100644 --- a/src/tools/cephfs/JournalTool.h +++ b/src/tools/cephfs/JournalTool.h @@ -37,6 +37,8 @@ class JournalTool : public MDSUtility // Bit hacky, use this `rank` member to control behaviour of the // various main_ functions. mds_rank_t rank; + // when set, generate per rank dump file path + bool all_ranks = false; std::string type; @@ -82,6 +84,9 @@ class JournalTool : public MDSUtility //validate type int validate_type(const std::string &type); + + // generate output file path for dump/export + std::string gen_dump_file_path(const std::string &prefix); public: static void usage(); JournalTool() :