Skip to content

Commit

Permalink
Merge PR #51539 into main
Browse files Browse the repository at this point in the history
* 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 <vshankar@redhat.com>
  • Loading branch information
vshankar committed Jul 18, 2023
2 parents 21ad525 + 93dfc11 commit 4e5d800
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 40 deletions.
4 changes: 2 additions & 2 deletions doc/cephfs/scrub.rst
Expand Up @@ -151,6 +151,6 @@ Evaluate strays using recursive scrub
ceph tell mds.<fsname>:0 scrub start ~mdsdir recursive

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

ceph tell mds.<fsname>:0 scrub start / scrub_mdsdir
ceph tell mds.<fsname>:0 scrub start / recursive,scrub_mdsdir
2 changes: 1 addition & 1 deletion qa/tasks/cephfs/test_scrub_checks.py
Expand Up @@ -374,7 +374,7 @@ def test_flag_scrub_mdsdir(self):
test flag scrub_mdsdir
"""
self.scrub_with_stray_evaluation(self.fs, self.mount_a, "/",
"scrub_mdsdir")
"recursive,scrub_mdsdir")

@staticmethod
def json_validator(json_out, rc, element, expected_value):
Expand Down
38 changes: 14 additions & 24 deletions src/mds/MDCache.cc
Expand Up @@ -12986,24 +12986,19 @@ class C_MDS_EnqueueScrub : public Context
std::string tag;
Formatter *formatter;
Context *on_finish;
bool dump_values;
public:
ScrubHeaderRef header;
C_MDS_EnqueueScrub(std::string_view tag, Formatter *f, Context *fin,
bool dump_values = true) :
tag(tag), formatter(f), on_finish(fin), dump_values(dump_values),
header(nullptr) {}
C_MDS_EnqueueScrub(std::string_view tag, Formatter *f, Context *fin) :
tag(tag), formatter(f), on_finish(fin), header(nullptr) {}

void finish(int r) override {
if (dump_values) {
formatter->open_object_section("results");
formatter->dump_int("return_code", r);
if (r == 0) {
formatter->dump_string("scrub_tag", tag);
formatter->dump_string("mode", "asynchronous");
}
formatter->close_section();
formatter->open_object_section("results");
formatter->dump_int("return_code", r);
if (r == 0) {
formatter->dump_string("scrub_tag", tag);
formatter->dump_string("mode", "asynchronous");
}
formatter->close_section();

r = 0;
if (on_finish)
Expand Down Expand Up @@ -13041,19 +13036,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);

Expand Down
7 changes: 0 additions & 7 deletions src/mds/MDSRank.cc
Expand Up @@ -2991,13 +2991,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!
Expand Down
20 changes: 14 additions & 6 deletions src/mds/ScrubStack.cc
Expand Up @@ -119,7 +119,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;
Expand Down Expand Up @@ -655,11 +668,6 @@ void ScrubStack::scrub_status(Formatter *f) {
have_more = false;
auto& header = p.second;

if (mdcache->get_inode(header->get_origin())->is_mdsdir()
&& header->get_scrub_mdsdir() && header->get_tag().empty()) {
continue;
}

std::string tag(header->get_tag());
f->open_object_section(tag.c_str()); // scrub id

Expand Down

0 comments on commit 4e5d800

Please sign in to comment.