]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: Add simple_dump() to FileJournal for unit testing
authorDavid Zafman <dzafman@redhat.com>
Wed, 18 Feb 2015 20:34:35 +0000 (12:34 -0800)
committerDavid Zafman <dzafman@redhat.com>
Wed, 13 May 2015 20:09:12 +0000 (13:09 -0700)
Allow a dump when entries aren't ObjectStore::Transaction's

Signed-off-by: David Zafman <dzafman@redhat.com>
src/os/FileJournal.cc
src/os/FileJournal.h

index 8b151f5dce67ab2914e99d82ff5e32452ff20e5d..0d34be68da3cb32b1724afd1dc378cb863adc868 100644 (file)
@@ -572,6 +572,16 @@ void FileJournal::close()
 
 
 int FileJournal::dump(ostream& out)
+{
+  return _dump(out, false);
+}
+
+int FileJournal::simple_dump(ostream& out)
+{
+  return _dump(out, true);
+}
+
+int FileJournal::_dump(ostream& out, bool simple)
 {
   dout(10) << "dump" << dendl;
 
@@ -637,20 +647,24 @@ int FileJournal::dump(ostream& out)
     f.open_object_section("entry");
     f.dump_unsigned("offset", pos);
     f.dump_unsigned("seq", seq);
-    f.open_array_section("transactions");
-    bufferlist::iterator p = bl.begin();
-    int trans_num = 0;
-    while (!p.end()) {
-      ObjectStore::Transaction *t = new ObjectStore::Transaction(p);
-      f.open_object_section("transaction");
-      f.dump_unsigned("trans_num", trans_num);
-      t->dump(&f);
+    if (simple) {
+      f.dump_unsigned("bl.length", bl.length());
+    } else {
+      f.open_array_section("transactions");
+      bufferlist::iterator p = bl.begin();
+      int trans_num = 0;
+      while (!p.end()) {
+        ObjectStore::Transaction *t = new ObjectStore::Transaction(p);
+        f.open_object_section("transaction");
+        f.dump_unsigned("trans_num", trans_num);
+        t->dump(&f);
+        f.close_section();
+        delete t;
+        trans_num++;
+      }
       f.close_section();
-      delete t;
-      trans_num++;
     }
     f.close_section();
-    f.close_section();
   }
 
   f.close_section();
index 0840f733fe9fd710e7b5f672d7c2ed0211c83628..964dbe721bc76587fc02164199e9c014da6b5275 100644 (file)
@@ -297,6 +297,7 @@ private:
   void _close(int fd) const;
   void _check_disk_write_cache() const;
   int _open_file(int64_t oldsize, blksize_t blksize, bool create);
+  int _dump(ostream& out, bool simple);
   void print_header(const header_t &hdr) const;
   int read_header(header_t *hdr) const;
   bufferptr prepare_header();
@@ -411,6 +412,7 @@ private:
   int peek_fsid(uuid_d& fsid);
 
   int dump(ostream& out);
+  int simple_dump(ostream& out);
 
   void flush();