]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
tools: cleanup phase of cephfs-data-scan
authorVishal Kanaujia <Vishal.Kanaujia@sandisk.com>
Tue, 6 Dec 2016 13:08:24 +0000 (18:38 +0530)
committerVishal Kanaujia <Vishal.Kanaujia@sandisk.com>
Tue, 6 Dec 2016 13:13:52 +0000 (18:43 +0530)
cephfs-data-scan has a new optional phase to delete xattrs generated
during recovery.

Signed-off-by: Vishal Kanaujia <vishal.kanaujia@sandisk.com>
doc/cephfs/disaster-recovery.rst
src/cls/cephfs/cls_cephfs_client.cc
src/cls/cephfs/cls_cephfs_client.h
src/tools/cephfs/DataScan.cc
src/tools/cephfs/DataScan.h

index ee54c90a70a63bb812fdf03bec4197e4d5db5dd7..8b6ffe90582ca8543eca5dcdd094e7b65bcbd5ca 100644 (file)
@@ -161,6 +161,13 @@ the range 0-(N_workers - 1), like so:
 It is important to ensure that all workers have completed the
 scan_extents phase before any workers enter the scan_inodes phase.
 
+After completing the metadata recovery, you may want to run cleanup
+operation to delete ancillary data geneated during recovery.
+
+::
+
+    cephfs-data-scan cleanup <data pool>
+
 Finding files affected by lost data PGs
 ---------------------------------------
 
index 9bc97aeb055fb7cc5ed4dbfe038d4668e13c78b2..17202bb384443220e1832dc621618e2ba1e1cfbc 100644 (file)
@@ -50,6 +50,21 @@ int ClsCephFSClient::accumulate_inode_metadata(
   return ctx.operate(zeroth_object.name, &op, &outbl);
 }
 
+int ClsCephFSClient::delete_inode_accumulate_result(
+    librados::IoCtx &ctx,
+    const std::string &oid)
+{
+  librados::ObjectWriteOperation op;
+
+  // Remove xattrs from object
+  //
+  op.rmxattr(XATTR_CEILING);
+  op.rmxattr(XATTR_MAX_SIZE);
+  op.rmxattr(XATTR_MAX_MTIME);
+
+  return (ctx.operate(oid, &op));
+}
+
 int ClsCephFSClient::fetch_inode_accumulate_result(
   librados::IoCtx &ctx,
   const std::string &oid,
index 51d12231230eb98cf11eb126c732be394b19d108..1305358f385a0d2a0d45a5129ebc7f65b32b2011 100644 (file)
@@ -23,6 +23,10 @@ class ClsCephFSClient
       file_layout_t *layout,
       AccumulateResult *result);
 
+  static int delete_inode_accumulate_result(
+      librados::IoCtx &ctx,
+      const std::string &oid);
+
   static void build_tag_filter(
       const std::string &scrub_tag,
       bufferlist *out_bl);
index 6cd3a508c56db35055e500cf3a94f895ce6bac04..951a01713539bd618a10819cc0933209967a0228 100644 (file)
@@ -42,6 +42,7 @@ void DataScan::usage()
     << "    --force-pool: use data pool even if it is not in FSMap\n"
     << "\n"
     << "  cephfs-data-scan scan_frags [--force-corrupt]\n"
+    << "  cephfs-data-scan cleanup <data pool name>\n"
     << std::endl;
 
   generic_client_usage();
@@ -165,7 +166,9 @@ int DataScan::main(const std::vector<const char*> &args)
 
     // Trailing positional argument
     if (i + 1 == args.end() &&
-        (command == "scan_inodes" || command == "scan_extents")) {
+        (command == "scan_inodes"
+         || command == "scan_extents"
+         || command == "cleanup")) {
       data_pool_name = *i;
       continue;
     }
@@ -235,7 +238,8 @@ int DataScan::main(const std::vector<const char*> &args)
 
   // Initialize data_io for those commands that need it
   if (command == "scan_inodes" ||
-      command == "scan_extents") {
+      command == "scan_extents" ||
+      command == "cleanup") {
     if (data_pool_name.empty()) {
       std::cerr << "Data pool not specified" << std::endl;
       usage();
@@ -300,6 +304,8 @@ int DataScan::main(const std::vector<const char*> &args)
     return scan_frags();
   } else if (command == "scan_links") {
     return scan_links();
+  } else if (command == "cleanup") {
+    return cleanup();
   } else if (command == "init") {
     return driver->init_roots(fs->mds_map.get_first_data_pool());
   } else {
@@ -844,6 +850,25 @@ int DataScan::scan_inodes()
   });
 }
 
+int DataScan::cleanup()
+{
+  // We are looking for only zeroth object
+  //
+  return forall_objects(data_io, true, [this](
+        std::string const &oid,
+        uint64_t obj_name_ino,
+        uint64_t obj_name_offset) -> int
+      {
+      int r = 0;
+      r = ClsCephFSClient::delete_inode_accumulate_result(data_io, oid);
+      if (r < 0) {
+      dout(4) << "Error deleting accumulated metadata from '"
+      << oid << "': " << cpp_strerror(r) << dendl;
+      }
+      return r;
+      });
+}
+
 bool DataScan::valid_ino(inodeno_t ino) const
 {
   return (ino >= inodeno_t((1ull << 40)))
index 462699d2224c86e7d73351159d65cf4446f4cb60..6c482e63382e79906e60cce4cfddb4fb712a40ce 100644 (file)
@@ -261,6 +261,11 @@ class DataScan : public MDSUtility, public MetadataTool
      */
     int scan_frags();
 
+    /**
+     * Cleanup xattrs from data pool
+     */
+    int cleanup();
+
     /**
      * Check if an inode number is in the permitted ranges
      */