From: John Spray Date: Mon, 19 May 2014 16:22:31 +0000 (+0100) Subject: tools/JournalTool: Fix 'header set' corner case X-Git-Tag: v0.82~48^2~6 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=b76e64b29b6899c355228cddd96b24d2e73b16e4;p=ceph.git tools/JournalTool: Fix 'header set' corner case 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 --- diff --git a/src/tools/cephfs/JournalScanner.cc b/src/tools/cephfs/JournalScanner.cc index cbc8b96636b..05d6db3f972 100644 --- a/src/tools/cephfs/JournalScanner.cc +++ b/src/tools/cephfs/JournalScanner.cc @@ -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; diff --git a/src/tools/cephfs/JournalTool.cc b/src/tools/cephfs/JournalTool.cc index 0a1a1b2f110..74dc7e255f8 100644 --- a/src/tools/cephfs/JournalTool.cc +++ b/src/tools/cephfs/JournalTool.cc @@ -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 \n" << " cephfs-journal-tool [options] event \n" << " : [--by-type=|--by-inode=|--by-path=|by-tree=|by-range=..|by-dirfrag-name=,]\n" @@ -165,15 +165,16 @@ int JournalTool::main_header(std::vector &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);