Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mds: enqueue ~mdsdir at the time of enqueing root #51539

Merged
merged 5 commits into from Jul 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 @@ -12960,24 +12960,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 @@ -13015,19 +13010,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 @@ -2986,13 +2986,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