From: John Spray Date: Thu, 8 May 2014 12:21:43 +0000 (+0100) Subject: tools: update Dumper to use JournalPointer X-Git-Tag: v0.82~48^2~19 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=aec4c939a766f5ef3d3cc2663f7c2715a7ec2d70;p=ceph.git tools: update Dumper to use JournalPointer Signed-off-by: John Spray --- diff --git a/src/tools/cephfs/Dumper.cc b/src/tools/cephfs/Dumper.cc index c47f88b8dfae..6ca58ed4e890 100644 --- a/src/tools/cephfs/Dumper.cc +++ b/src/tools/cephfs/Dumper.cc @@ -22,6 +22,7 @@ #include "common/safe_io.h" #include "mds/mdstypes.h" #include "mds/LogEvent.h" +#include "mds/JournalPointer.h" #include "osdc/Journaler.h" #include "Dumper.h" @@ -38,14 +39,19 @@ int Dumper::init(int rank_) return r; } - inodeno_t ino = MDS_INO_LOG_OFFSET + rank; - journaler = new Journaler(ino, mdsmap->get_metadata_pool(), CEPH_FS_ONDISK_MAGIC, - objecter, 0, 0, &timer); - return 0; + JournalPointer jp(rank, mdsmap->get_metadata_pool()); + int jp_load_result = jp.load(objecter, &lock); + if (jp_load_result != 0) { + std::cerr << "Error loading journal: " << cpp_strerror(jp_load_result) << std::endl; + return jp_load_result; + } else { + ino = jp.front; + return 0; + } } -int Dumper::recover_journal() +int Dumper::recover_journal(Journaler *journaler) { bool done = false; Cond cond; @@ -77,14 +83,15 @@ void Dumper::dump(const char *dump_file) Cond cond; Mutex localLock("dump:lock"); - r = recover_journal(); + Journaler journaler(ino, mdsmap->get_metadata_pool(), CEPH_FS_ONDISK_MAGIC, + objecter, 0, 0, &timer); + r = recover_journal(&journaler); if (r) { return; } - uint64_t start = journaler->get_read_pos(); - uint64_t end = journaler->get_write_pos(); + uint64_t start = journaler.get_read_pos(); + uint64_t end = journaler.get_write_pos(); uint64_t len = end-start; - inodeno_t ino = MDS_INO_LOG_OFFSET + rank; cout << "journal is " << start << "~" << len << std::endl; @@ -92,7 +99,7 @@ void Dumper::dump(const char *dump_file) bufferlist bl; lock.Lock(); - filer.read(ino, &journaler->get_layout(), CEPH_NOSNAP, + filer.read(ino, &journaler.get_layout(), CEPH_NOSNAP, start, len, &bl, 0, new C_SafeCond(&localLock, &cond, &done)); lock.Unlock(); localLock.Lock(); @@ -159,8 +166,6 @@ void Dumper::undump(const char *dump_file) cout << "start " << start << " len " << len << std::endl; - inodeno_t ino = MDS_INO_LOG_OFFSET + rank; - Journaler::Header h; h.trimmed_pos = start; h.expire_pos = start; diff --git a/src/tools/cephfs/Dumper.h b/src/tools/cephfs/Dumper.h index 0df861e43fe3..1986eca34feb 100644 --- a/src/tools/cephfs/Dumper.h +++ b/src/tools/cephfs/Dumper.h @@ -16,7 +16,8 @@ #include "MDSUtility.h" -#include "osdc/Journaler.h" + +class Journaler; /** * This class lets you dump out an mds journal for troubleshooting or whatever. @@ -28,17 +29,17 @@ class Dumper : public MDSUtility { private: - Journaler *journaler; int rank; + inodeno_t ino; public: - Dumper() : journaler(NULL), rank(-1) + Dumper() : rank(-1), ino(-1) {} void handle_mds_map(MMDSMap* m); int init(int rank); - int recover_journal(); + int recover_journal(Journaler *journaler); void dump(const char *dumpfile); void undump(const char *dumpfile); };