]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: evaluate strays while performing scrub on root path
authordparmar18 <dparmar@redhat.com>
Mon, 12 Sep 2022 11:46:00 +0000 (17:16 +0530)
committerDhairya Parmar <dparmar@redhat.com>
Fri, 31 Mar 2023 10:18:34 +0000 (15:48 +0530)
Running scrub at CephFS root doesn't iterate over ~mdsdir,
this feature is needed but the cluster admin should have
the liberty to decide whether to evaluate strays at root
or not. Therefore a new option 'scrub_mdsdir' can be useful.

Fixes: https://tracker.ceph.com/issues/53724
Signed-off-by: Dhairya Parmar <dparmar@redhat.com>
(cherry picked from commit e65eb2bb7895287c068691afe7a7a1710af0d360)

src/mds/MDSDaemon.cc
src/mds/MDSRank.cc

index e45cb142b7aeaa9726094fe7cb4417c28756f9c3..caeaa41cf4afe9c6f916786c878fb466228dd432 100644 (file)
@@ -282,7 +282,7 @@ void MDSDaemon::set_up_admin_socket()
   ceph_assert(r == 0);
   r = admin_socket->register_command("scrub start "
                                     "name=path,type=CephString "
-                                    "name=scrubops,type=CephChoices,strings=force|recursive|repair,n=N,req=false "
+                                    "name=scrubops,type=CephChoices,strings=force|recursive|repair|scrub_mdsdir,n=N,req=false "
                                     "name=tag,type=CephString,req=false",
                                     asok_hook,
                                     "scrub and inode and output results");
index 014ee06317aea70bdaedbf6a51bea699bc09915a..411f7f559d2cbc06a99586a1cc30350397ed2479 100644 (file)
@@ -2961,6 +2961,7 @@ void MDSRank::command_scrub_start(Formatter *f,
   bool force = false;
   bool recursive = false;
   bool repair = false;
+  bool scrub_mdsdir = false;
   for (auto &op : scrubop_vec) {
     if (op == "force")
       force = true;
@@ -2968,9 +2969,17 @@ void MDSRank::command_scrub_start(Formatter *f,
       recursive = true;
     else if (op == "repair")
       repair = true;
+    else if (op == "scrub_mdsdir" && path == "/")
+      scrub_mdsdir = true;
   }
 
   std::lock_guard l(mds_lock);
+  if (scrub_mdsdir) {
+    MDSGatherBuilder gather(g_ceph_context);
+    mdcache->enqueue_scrub("~mdsdir", tag, false, true, false, f, gather.new_sub());
+    gather.set_finisher(new C_MDSInternalNoop);
+    gather.activate();
+  }
   mdcache->enqueue_scrub(path, tag, force, recursive, repair, f, on_finish);
   // scrub_dentry() finishers will dump the data for us; we're done!
 }