From: Dhairya Parmar Date: Mon, 22 May 2023 07:04:51 +0000 (+0530) Subject: mds: enqueue ~mdsdir at the time of enqueing root X-Git-Tag: v16.2.14~51^2~4 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=ddf493cd2ec36c32b11b040fa075c891c308033c;p=ceph.git mds: enqueue ~mdsdir at the time of enqueing root 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 (cherry picked from commit f85b22818b474911cfdc15e7c6be1d2979939888) --- diff --git a/src/mds/MDCache.cc b/src/mds/MDCache.cc index bb2f2c7d5a5..5371cba5908 100644 --- a/src/mds/MDCache.cc +++ b/src/mds/MDCache.cc @@ -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(tag_str, is_internal, force, recursive, repair, scrub_mdsdir); diff --git a/src/mds/MDSRank.cc b/src/mds/MDSRank.cc index 68a8cfacec8..96df73f8331 100644 --- a/src/mds/MDSRank.cc +++ b/src/mds/MDSRank.cc @@ -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! diff --git a/src/mds/ScrubStack.cc b/src/mds/ScrubStack.cc index 8f3d591ed4f..6c2a6ac1a10 100644 --- a/src/mds/ScrubStack.cc +++ b/src/mds/ScrubStack.cc @@ -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;