]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/tools/cephfs/Dumper.cc
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / tools / cephfs / Dumper.cc
index 1799552bfdf18c9da76b65752b7a509c5aa8f149..11d32523f416e46b705198681a8af21d2aaab6fb 100644 (file)
@@ -34,7 +34,7 @@
 
 #define HEADER_LEN 4096
 
-int Dumper::init(mds_role_t role_)
+int Dumper::init(mds_role_t role_, const std::string &type)
 {
   role = role_;
 
@@ -44,17 +44,23 @@ int Dumper::init(mds_role_t role_)
   }
 
   auto fs =  fsmap->get_filesystem(role.fscid);
-  assert(fs != nullptr);
-
-  JournalPointer jp(role.rank, fs->mds_map.get_metadata_pool());
-  int jp_load_result = jp.load(objecter);
-  if (jp_load_result != 0) {
-    std::cerr << "Error loading journal: " << cpp_strerror(jp_load_result) << std::endl;
-    return jp_load_result;
+  ceph_assert(fs != nullptr);
+
+  if (type == "mdlog") {
+    JournalPointer jp(role.rank, fs->mds_map.get_metadata_pool());
+    int jp_load_result = jp.load(objecter);
+    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;
+    }
+  } else if (type == "purge_queue") {
+    ino = MDS_INO_PURGE_QUEUE + role.rank;
   } else {
-    ino = jp.front;
-    return 0;
+    ceph_abort(); // should not get here 
   }
+  return 0;
 }
 
 
@@ -81,7 +87,7 @@ int Dumper::dump(const char *dump_file)
   int r = 0;
 
   auto fs =  fsmap->get_filesystem(role.fscid);
-  assert(fs != nullptr);
+  ceph_assert(fs != nullptr);
 
   Journaler journaler("dumper", ino, fs->mds_map.get_metadata_pool(),
                       CEPH_FS_ONDISK_MAGIC, objecter, 0, 0,
@@ -146,7 +152,7 @@ int Dumper::dump(const char *dump_file)
       bufferlist bl;
       dout(10) << "Reading at pos=0x" << std::hex << pos << std::dec << dendl;
 
-      const uint32_t read_size = MIN(chunk_size, end - pos);
+      const uint32_t read_size = std::min<uint64_t>(chunk_size, end - pos);
 
       C_SaferCond cond;
       lock.Lock();
@@ -195,7 +201,7 @@ int Dumper::undump(const char *dump_file, bool force)
   cout << "undump " << dump_file << std::endl;
   
   auto fs =  fsmap->get_filesystem(role.fscid);
-  assert(fs != nullptr);
+  ceph_assert(fs != nullptr);
 
   int r = 0;
   // try get layout info from cluster
@@ -325,7 +331,7 @@ int Dumper::undump(const char *dump_file, bool force)
   h.layout.pool_id = fs->mds_map.get_metadata_pool();
   
   bufferlist hbl;
-  ::encode(h, hbl);
+  encode(h, hbl);
 
   object_t oid = file_object_t(ino, 0);
   object_locator_t oloc(fs->mds_map.get_metadata_pool());
@@ -355,7 +361,7 @@ int Dumper::undump(const char *dump_file, bool force)
    * prezeroing behaviour */
   {
     uint32_t const object_size = h.layout.object_size;
-    assert(object_size > 0);
+    ceph_assert(object_size > 0);
     uint64_t last_obj = h.write_pos / object_size;
     uint64_t purge_count = 2;
     /* When the length is zero, the last_obj should be zeroed 
@@ -395,7 +401,7 @@ int Dumper::undump(const char *dump_file, bool force)
     // Read
     bufferlist j;
     lseek64(fd, pos, SEEK_SET);
-    uint64_t l = MIN(left, 1024*1024);
+    uint64_t l = std::min<uint64_t>(left, 1024*1024);
     j.read_fd(fd, l);
 
     // Write