]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cephfs-journal-tool: dump to per rank output file wherever necessary
authorVenky Shankar <vshankar@redhat.com>
Mon, 23 Jul 2018 06:28:07 +0000 (02:28 -0400)
committerVenky Shankar <vshankar@redhat.com>
Mon, 3 Dec 2018 07:39:49 +0000 (02:39 -0500)
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 <vshankar@redhat.com>
(cherry picked from commit cb19db75c7f23278d2598b58526d1bf8bf00b679)

 Conflicts:
src/tools/cephfs/JournalTool.h

src/tools/cephfs/JournalTool.cc
src/tools/cephfs/JournalTool.h

index a66cc2d70ba565f31b8853f2eb3898cfe466b597..291ba775553788b1d6b173c14b047f7c60246e22 100644 (file)
@@ -169,6 +169,14 @@ int JournalTool::main(std::vector<const char*> &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<const char*> &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<const char*> &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());
     }
   }
 
index 2edeb6a76535c4e2f755634cda38aa6e26b8ee93..2f904e2397ca691f751d6b73b710076ddcf054c1 100644 (file)
@@ -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<const char*> &argv);
     int main_header(std::vector<const char*> &argv);
@@ -78,6 +81,9 @@ class JournalTool : public MDSUtility
         bufferlist *out_bl);
     int consume_inos(const std::set<inodeno_t> &inos);
 
+    // generate output file path for dump/export
+    std::string gen_dump_file_path(const std::string &prefix);
+
   public:
     void usage();
     JournalTool() :