]> git.apps.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:14:12 +0000 (15:44 +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 4aa4815d1f424095a0222ac72e65ebd37ef0ed75..0c01593a2d3398f21735a371f159839b706643d1 100644 (file)
@@ -276,7 +276,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 bae7706f6ad2f3c9062dcb78d7d6cdd8fe51f564..f177e57a4f4722eabc85a8b108f81b5a8381535b 100644 (file)
@@ -2949,6 +2949,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;
@@ -2956,9 +2957,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!
 }