From c906a88576a9a5fc538803cc27dcbd69a590dcb0 Mon Sep 17 00:00:00 2001 From: dparmar18 Date: Mon, 12 Sep 2022 17:16:00 +0530 Subject: [PATCH] mds: evaluate strays while performing scrub on root path 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 (cherry picked from commit e65eb2bb7895287c068691afe7a7a1710af0d360) --- src/mds/MDSDaemon.cc | 2 +- src/mds/MDSRank.cc | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/mds/MDSDaemon.cc b/src/mds/MDSDaemon.cc index 4aa4815d1f424..0c01593a2d339 100644 --- a/src/mds/MDSDaemon.cc +++ b/src/mds/MDSDaemon.cc @@ -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"); diff --git a/src/mds/MDSRank.cc b/src/mds/MDSRank.cc index bae7706f6ad2f..f177e57a4f472 100644 --- a/src/mds/MDSRank.cc +++ b/src/mds/MDSRank.cc @@ -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! } -- 2.39.5