From: John Spray Date: Wed, 21 May 2014 12:36:26 +0000 (+0100) Subject: tools/cephfs: error handling in journal_export X-Git-Tag: v0.83~86^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=ac057999eb6f067efae06eb2cfe7403ec077491c;p=ceph.git tools/cephfs: error handling in journal_export 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 --- diff --git a/src/tools/cephfs/JournalTool.cc b/src/tools/cephfs/JournalTool.cc index fa6bf2b1bd27..976376c78ba5 100644 --- a/src/tools/cephfs/JournalTool.cc +++ b/src/tools/cephfs/JournalTool.cc @@ -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; }