]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
tools/JournalTool: Fix 'header set' corner case
authorJohn Spray <john.spray@inktank.com>
Mon, 19 May 2014 16:22:31 +0000 (17:22 +0100)
committerJohn Spray <john.spray@inktank.com>
Tue, 20 May 2014 13:07:52 +0000 (14:07 +0100)
If the write_pos was behind the other pointers, we
would flag the header as invalid.  However, that
would prevent doing a "header set" to correct it.

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

index cbc8b96636b96a18172234dfcc271477c819c040..05d6db3f97228c4f166fc3258af04127ef88e2a2 100644 (file)
@@ -111,6 +111,8 @@ int JournalScanner::scan_header()
   catch (buffer::error e)
   {
     derr << "Header is corrupt (" << e.what() << ")" << dendl;
+    delete header;
+    header = NULL;
     return 0;  // "Successfully" found an error
   }
 
@@ -119,7 +121,7 @@ int JournalScanner::scan_header()
     return 0;  // "Successfully" found an error
   }
   if (!((header->trimmed_pos <= header->expire_pos) && (header->expire_pos <= header->write_pos))) {
-    derr << "Header is corrupt (inconsistent offsets)" << dendl;
+    derr << "Header is invalid (inconsistent offsets)" << dendl;
     return 0;  // "Successfully" found an error
   }
   header_valid = true;
index 0a1a1b2f1105b7bc014911fcabdd474a4e9760e9..74dc7e255f81726d9a264d871e62be655ba619de 100644 (file)
@@ -38,7 +38,7 @@
 void JournalTool::usage()
 {
   std::cout << "Usage: \n"
-    << "  cephfs-journal-tool [options] journal [inspect|import|export]\n"
+    << "  cephfs-journal-tool [options] journal [inspect|import|export|reset]\n"
     << "  cephfs-journal-tool [options] header <get|set <field> <value>\n"
     << "  cephfs-journal-tool [options] event <selector> <effect> <output>\n"
     << "    <selector>:  [--by-type=<metablob|client|mds|...?>|--by-inode=<inode>|--by-path=<path>|by-tree=<path>|by-range=<N>..<M>|by-dirfrag-name=<dirfrag id>,<name>]\n"
@@ -165,15 +165,16 @@ int JournalTool::main_header(std::vector<const char*> &argv)
   JournalScanner js(io, rank, filter);
   int r = js.scan(false);
   if (r < 0) {
-    derr << "Unable to scan journal" << dendl;
+    std::cerr << "Unable to scan journal" << std::endl;
     return r;
   }
 
   if (!js.header_present) {
-    derr << "Header object not found!" << dendl;
+    std::cerr << "Header object not found!" << std::endl;
     return -ENOENT;
-  } else if (!js.header_valid) {
-    derr << "Header invalid!" << dendl;
+  } else if (!js.header_valid && js.header == NULL) {
+    // Can't do a read or a single-field write without a copy of the original
+    derr << "Header could not be read!" << dendl;
     return -ENOENT;
   } else {
     assert(js.header != NULL);