]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
tools/cephfs: error handling in journal_export
authorJohn Spray <john.spray@inktank.com>
Wed, 21 May 2014 12:36:26 +0000 (13:36 +0100)
committerJohn Spray <john.spray@redhat.com>
Fri, 13 Jun 2014 10:39:17 +0000 (11:39 +0100)
Was failing on unreadable journal even if
only trying to do an import.

Was calling messenger destructor without init
on early failures due to early instantiation
of Dumper.

Signed-off-by: John Spray <john.spray@inktank.com>
src/tools/cephfs/JournalTool.cc

index fa6bf2b1bd2781ebe400cba5976a87847520d857..976376c78ba51e3d724047917c3a8d0e98566934 100644 (file)
@@ -433,37 +433,41 @@ int JournalTool::journal_inspect()
 int JournalTool::journal_export(std::string const &path, bool import)
 {
   int r = 0;
-  Dumper dumper;
   JournalScanner js(io, rank);
 
-  /*
-   * Check that the header is valid and no objects are missing before
-   * trying to dump
-   */
-  r = js.scan();
-  if (r < 0) {
-    derr << "Unable to scan journal, assuming badly damaged" << dendl;
-    return r;
-  }
-  if (!js.is_readable()) {
-    derr << "Journal not readable, attempt object-by-object dump with `rados`" << dendl;
-    return -EIO;
+  if (!import) {
+    /*
+     * If doing an export, first check that the header is valid and
+     * no objects are missing before trying to dump
+     */
+    r = js.scan();
+    if (r < 0) {
+      derr << "Unable to scan journal, assuming badly damaged" << dendl;
+      return r;
+    }
+    if (!js.is_readable()) {
+      derr << "Journal not readable, attempt object-by-object dump with `rados`" << dendl;
+      return -EIO;
+    }
   }
 
   /*
    * Assuming we can cleanly read the journal data, dump it out to a file
    */
-  r = dumper.init(rank);
-  if (r < 0) {
-    derr << "dumper::init failed: " << cpp_strerror(r) << dendl;
-    return r;
-  }
-  if (import) {
-    dumper.undump(path.c_str());
-  } else {
-    dumper.dump(path.c_str());
+  {
+    Dumper dumper;
+    r = dumper.init(rank);
+    if (r < 0) {
+      derr << "dumper::init failed: " << cpp_strerror(r) << dendl;
+      return r;
+    }
+    if (import) {
+      dumper.undump(path.c_str());
+    } else {
+      dumper.dump(path.c_str());
+    }
+    dumper.shutdown();
   }
-  dumper.shutdown();
 
   return r;
 }