]> git.apps.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>
Fri, 21 Sep 2018 10:09:39 +0000 (06:09 -0400)
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>
src/tools/cephfs/JournalTool.cc
src/tools/cephfs/JournalTool.h

index 227b334f8eb4d68563e1f7790755afcb466ad965..0ad770a95eb28611f182a825db159fbf1e557458 100644 (file)
@@ -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<const char*> &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<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();
@@ -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());
     }
   }
 
index 87f37691ae220dc82dfa6a3a46dfad1d9ff1d4d9..081e140e8f21e1c7d421d51d870d258450413a29 100644 (file)
@@ -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() :