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: v12.2.11~96^2~4 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=fd09bc7cdf6b83b87dee85824d33b146d858be6f;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 (cherry picked from commit cb19db75c7f23278d2598b58526d1bf8bf00b679) Conflicts: src/tools/cephfs/JournalTool.h --- diff --git a/src/tools/cephfs/JournalTool.cc b/src/tools/cephfs/JournalTool.cc index a66cc2d70ba..291ba775553 100644 --- a/src/tools/cephfs/JournalTool.cc +++ b/src/tools/cephfs/JournalTool.cc @@ -169,6 +169,14 @@ int JournalTool::main(std::vector &argv) } +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 * @@ -376,6 +384,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, filter); @@ -493,7 +503,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(); @@ -580,7 +590,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 2edeb6a7653..2f904e2397c 100644 --- a/src/tools/cephfs/JournalTool.h +++ b/src/tools/cephfs/JournalTool.h @@ -38,6 +38,9 @@ class JournalTool : public MDSUtility // various main_ functions. mds_rank_t rank; + // when set, generate per rank dump file path + bool all_ranks = false; + // Entry points int main_journal(std::vector &argv); int main_header(std::vector &argv); @@ -78,6 +81,9 @@ class JournalTool : public MDSUtility bufferlist *out_bl); int consume_inos(const std::set &inos); + // generate output file path for dump/export + std::string gen_dump_file_path(const std::string &prefix); + public: void usage(); JournalTool() :