Skip to content

Commit

Permalink
Merge PR ceph#44342 into master
Browse files Browse the repository at this point in the history
* refs/pull/44342/head:
	mds: trigger stray reintegration when loading dentry
	qa: test that scrub causes reintegration

Reviewed-by: Xiubo Li <[email protected]>
  • Loading branch information
batrick committed Dec 27, 2021
2 parents 8fe3a1b + 83f9a49 commit 135be96
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 1 deletion.
7 changes: 6 additions & 1 deletion qa/tasks/cephfs/filesystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -1163,7 +1163,12 @@ def rank_asok(self, command, rank=0, status=None, timeout=None):
return self.json_asok(command, 'mds', info['name'], timeout=timeout)

def rank_tell(self, command, rank=0, status=None):
return json.loads(self.mon_manager.raw_cluster_cmd("tell", f"mds.{self.id}:{rank}", *command))
try:
out = self.mon_manager.raw_cluster_cmd("tell", f"mds.{self.id}:{rank}", *command)
return json.loads(out)
except json.decoder.JSONDecodeError:
log.error("could not decode: {}".format(out))
raise

def ranks_tell(self, command, status=None):
if status is None:
Expand Down
51 changes: 51 additions & 0 deletions qa/tasks/cephfs/test_strays.py
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,57 @@ def test_hardlink_reintegration(self):
# We purged it at the last
self.assertEqual(self.get_mdc_stat("strays_enqueued"), 1)

def test_reintegration_via_scrub(self):
"""
That reintegration is triggered via recursive scrub.
"""

self.mount_a.run_shell_payload("""
mkdir -p a b
for i in `seq 1 50`; do
touch a/"$i"
ln a/"$i" b/"$i"
done
sync -f .
""")

self.mount_a.remount() # drop caps/cache
self.fs.rank_tell(["flush", "journal"])
self.fs.rank_fail()
self.fs.wait_for_daemons()

# only / in cache, reintegration cannot happen
self.wait_until_equal(
lambda: len(self.fs.rank_tell(["dump", "tree", "/"])),
expect_val=3,
timeout=60
)

last_reintegrated = self.get_mdc_stat("strays_reintegrated")
self.mount_a.run_shell_payload("""
rm a/*
sync -f .
""")
self.wait_until_equal(
lambda: len(self.fs.rank_tell(["dump", "tree", "/"])),
expect_val=3,
timeout=60
)
self.assertEqual(self.get_mdc_stat("num_strays"), 50)
curr_reintegrated = self.get_mdc_stat("strays_reintegrated")
self.assertEqual(last_reintegrated, curr_reintegrated)

self.fs.rank_tell(["scrub", "start", "/", "recursive,force"])

self.wait_until_equal(
lambda: self.get_mdc_stat("num_strays"),
expect_val=0,
timeout=60
)
curr_reintegrated = self.get_mdc_stat("strays_reintegrated")
# N.B.: reintegrate (rename RPC) may be tried multiple times from different code paths
self.assertGreaterEqual(curr_reintegrated, last_reintegrated+50)

def test_mv_hardlink_cleanup(self):
"""
That when doing a rename from A to B, and B has hardlinks,
Expand Down
3 changes: 3 additions & 0 deletions src/mds/CDentry.cc
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,9 @@ void CDentry::link_remote(CDentry::linkage_t *dnl, CInode *in)

if (dnl == &linkage)
in->add_remote_parent(this);

// check for reintegration
dir->mdcache->eval_remote(this);
}

void CDentry::unlink_remote(CDentry::linkage_t *dnl)
Expand Down

0 comments on commit 135be96

Please sign in to comment.