]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: enqueue ~mdsdir at the time of enqueing root
authorDhairya Parmar <dparmar@redhat.com>
Mon, 22 May 2023 07:04:51 +0000 (12:34 +0530)
committerDhairya Parmar <dparmar@redhat.com>
Tue, 18 Jul 2023 17:02:16 +0000 (22:32 +0530)
This would avoid the need to run individual scrubs for
~mdsdir and root, i.e. run both the scrubs under the
same header, this also helps to avoid edge case where
in case ~mdsdir is huge and it's taking time to scrub it,
the scrub status would report something like this until
root inodes kick in:

{
    "status": "scrub active (757 inodes in the stack)",
    "scrubs": {}
}

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

src/mds/MDCache.cc
src/mds/MDSRank.cc
src/mds/ScrubStack.cc

index bb2f2c7d5a59b8ed36a6323b31fb3e5158291a6d..5371cba5908ffec1a3fdbfd2b40637c2513bc8d6 100644 (file)
@@ -12811,19 +12811,14 @@ void MDCache::enqueue_scrub(
 
   bool is_internal = false;
   std::string tag_str(tag);
-  C_MDS_EnqueueScrub *cs;
-  if ((path == "~mdsdir" && scrub_mdsdir)) {
+  if (tag_str.empty()) {
+    uuid_d uuid_gen;
+    uuid_gen.generate_random();
+    tag_str = uuid_gen.to_string();
     is_internal = true;
-    cs = new C_MDS_EnqueueScrub(tag_str, f, fin, false);
-  } else {
-    if (tag_str.empty()) {
-      uuid_d uuid_gen;
-      uuid_gen.generate_random();
-      tag_str = uuid_gen.to_string();
-      is_internal = true;
-    }
-    cs = new C_MDS_EnqueueScrub(tag_str, f, fin);
   }
+
+  C_MDS_EnqueueScrub *cs = new C_MDS_EnqueueScrub(tag_str, f, fin);
   cs->header = std::make_shared<ScrubHeader>(tag_str, is_internal, force,
                                              recursive, repair, scrub_mdsdir);
 
index 68a8cfacec8682b98eb09e6b4a81a957c72d4604..96df73f833134757c95256fb5668d86c785db6bd 100644 (file)
@@ -2962,13 +2962,6 @@ void MDSRank::command_scrub_start(Formatter *f,
   }
 
   std::lock_guard l(mds_lock);
-  if (scrub_mdsdir) {
-    MDSGatherBuilder gather(g_ceph_context);
-    mdcache->enqueue_scrub("~mdsdir", "", false, true, false, scrub_mdsdir,
-                           f, gather.new_sub());
-    gather.set_finisher(new C_MDSInternalNoop);
-    gather.activate();
-  }
   mdcache->enqueue_scrub(path, tag, force, recursive, repair, scrub_mdsdir,
                          f, on_finish);
   // scrub_dentry() finishers will dump the data for us; we're done!
index 8f3d591ed4f57021b2c385941b135251740b872b..6c2a6ac1a104ef641bc0e556cd986d4b31b6f43b 100644 (file)
@@ -116,7 +116,20 @@ int ScrubStack::enqueue(CInode *in, ScrubHeaderRef& header, bool top)
             << ", conflicting tag " << header->get_tag() << dendl;
     return -CEPHFS_EEXIST;
   }
-
+  if (header->get_scrub_mdsdir()) {
+    filepath fp;
+    mds_rank_t rank;
+    rank = mdcache->mds->get_nodeid();
+    if(rank >= 0 && rank < MAX_MDS) {
+      fp.set_path("", MDS_INO_MDSDIR(rank));
+    }
+    int r = _enqueue(mdcache->get_inode(fp.get_ino()), header, true);
+    if (r < 0) {
+      return r;
+    }
+    //to make sure mdsdir is always on the top
+    top = false;
+  }
   int r = _enqueue(in, header, top);
   if (r < 0)
     return r;