Skip to content

Commit 4e5d800

Browse files
committed
Merge PR ceph#51539 into main
* refs/pull/51539/head: doc: users now need to provide scrub_mdsdir and recursive flags qa: add recursive flag to test_flag_scrub_mdsdir mds: remove code to bypass dumping empty header scrub info mds: dump_values no more needed mds: enqueue ~mdsdir at the time of enqueing root Reviewed-by: Venky Shankar <[email protected]>
2 parents 21ad525 + 93dfc11 commit 4e5d800

File tree

5 files changed

+31
-40
lines changed

5 files changed

+31
-40
lines changed

doc/cephfs/scrub.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,6 @@ Evaluate strays using recursive scrub
151151
ceph tell mds.<fsname>:0 scrub start ~mdsdir recursive
152152

153153
- ``~mdsdir`` is not enqueued by default when scrubbing at the CephFS root. In order to perform stray evaluation
154-
at root, run scrub with flag ``scrub_mdsdir``::
154+
at root, run scrub with flags ``scrub_mdsdir`` and ``recursive``::
155155

156-
ceph tell mds.<fsname>:0 scrub start / scrub_mdsdir
156+
ceph tell mds.<fsname>:0 scrub start / recursive,scrub_mdsdir

qa/tasks/cephfs/test_scrub_checks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ def test_flag_scrub_mdsdir(self):
374374
test flag scrub_mdsdir
375375
"""
376376
self.scrub_with_stray_evaluation(self.fs, self.mount_a, "/",
377-
"scrub_mdsdir")
377+
"recursive,scrub_mdsdir")
378378

379379
@staticmethod
380380
def json_validator(json_out, rc, element, expected_value):

src/mds/MDCache.cc

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -12986,24 +12986,19 @@ class C_MDS_EnqueueScrub : public Context
1298612986
std::string tag;
1298712987
Formatter *formatter;
1298812988
Context *on_finish;
12989-
bool dump_values;
1299012989
public:
1299112990
ScrubHeaderRef header;
12992-
C_MDS_EnqueueScrub(std::string_view tag, Formatter *f, Context *fin,
12993-
bool dump_values = true) :
12994-
tag(tag), formatter(f), on_finish(fin), dump_values(dump_values),
12995-
header(nullptr) {}
12991+
C_MDS_EnqueueScrub(std::string_view tag, Formatter *f, Context *fin) :
12992+
tag(tag), formatter(f), on_finish(fin), header(nullptr) {}
1299612993

1299712994
void finish(int r) override {
12998-
if (dump_values) {
12999-
formatter->open_object_section("results");
13000-
formatter->dump_int("return_code", r);
13001-
if (r == 0) {
13002-
formatter->dump_string("scrub_tag", tag);
13003-
formatter->dump_string("mode", "asynchronous");
13004-
}
13005-
formatter->close_section();
12995+
formatter->open_object_section("results");
12996+
formatter->dump_int("return_code", r);
12997+
if (r == 0) {
12998+
formatter->dump_string("scrub_tag", tag);
12999+
formatter->dump_string("mode", "asynchronous");
1300613000
}
13001+
formatter->close_section();
1300713002

1300813003
r = 0;
1300913004
if (on_finish)
@@ -13041,19 +13036,14 @@ void MDCache::enqueue_scrub(
1304113036

1304213037
bool is_internal = false;
1304313038
std::string tag_str(tag);
13044-
C_MDS_EnqueueScrub *cs;
13045-
if ((path == "~mdsdir" && scrub_mdsdir)) {
13039+
if (tag_str.empty()) {
13040+
uuid_d uuid_gen;
13041+
uuid_gen.generate_random();
13042+
tag_str = uuid_gen.to_string();
1304613043
is_internal = true;
13047-
cs = new C_MDS_EnqueueScrub(tag_str, f, fin, false);
13048-
} else {
13049-
if (tag_str.empty()) {
13050-
uuid_d uuid_gen;
13051-
uuid_gen.generate_random();
13052-
tag_str = uuid_gen.to_string();
13053-
is_internal = true;
13054-
}
13055-
cs = new C_MDS_EnqueueScrub(tag_str, f, fin);
1305613044
}
13045+
13046+
C_MDS_EnqueueScrub *cs = new C_MDS_EnqueueScrub(tag_str, f, fin);
1305713047
cs->header = std::make_shared<ScrubHeader>(tag_str, is_internal, force,
1305813048
recursive, repair, scrub_mdsdir);
1305913049

src/mds/MDSRank.cc

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2991,13 +2991,6 @@ void MDSRank::command_scrub_start(Formatter *f,
29912991
}
29922992

29932993
std::lock_guard l(mds_lock);
2994-
if (scrub_mdsdir) {
2995-
MDSGatherBuilder gather(g_ceph_context);
2996-
mdcache->enqueue_scrub("~mdsdir", "", false, true, false, scrub_mdsdir,
2997-
f, gather.new_sub());
2998-
gather.set_finisher(new C_MDSInternalNoop);
2999-
gather.activate();
3000-
}
30012994
mdcache->enqueue_scrub(path, tag, force, recursive, repair, scrub_mdsdir,
30022995
f, on_finish);
30032996
// scrub_dentry() finishers will dump the data for us; we're done!

src/mds/ScrubStack.cc

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,20 @@ int ScrubStack::enqueue(CInode *in, ScrubHeaderRef& header, bool top)
119119
<< ", conflicting tag " << header->get_tag() << dendl;
120120
return -CEPHFS_EEXIST;
121121
}
122-
122+
if (header->get_scrub_mdsdir()) {
123+
filepath fp;
124+
mds_rank_t rank;
125+
rank = mdcache->mds->get_nodeid();
126+
if(rank >= 0 && rank < MAX_MDS) {
127+
fp.set_path("", MDS_INO_MDSDIR(rank));
128+
}
129+
int r = _enqueue(mdcache->get_inode(fp.get_ino()), header, true);
130+
if (r < 0) {
131+
return r;
132+
}
133+
//to make sure mdsdir is always on the top
134+
top = false;
135+
}
123136
int r = _enqueue(in, header, top);
124137
if (r < 0)
125138
return r;
@@ -655,11 +668,6 @@ void ScrubStack::scrub_status(Formatter *f) {
655668
have_more = false;
656669
auto& header = p.second;
657670

658-
if (mdcache->get_inode(header->get_origin())->is_mdsdir()
659-
&& header->get_scrub_mdsdir() && header->get_tag().empty()) {
660-
continue;
661-
}
662-
663671
std::string tag(header->get_tag());
664672
f->open_object_section(tag.c_str()); // scrub id
665673

0 commit comments

Comments
 (0)