Skip to content

Commit

Permalink
mds: fix issuing redundant reintegrate/migrate_stray requests
Browse files Browse the repository at this point in the history
Just in case a CInode's nlink is 1, and then a unlink request comes
and then early replies and submits to the MDLogs, but just before
the MDlogs are flushed a link request comes, and the link request
also succeeds and early replies to client.

Later when the unlink/link requests' MDLog events are flushed and
the callbacks are called, which will fire a stray denty reintegration.
But it will pick the new dentry, which is from the link's request
and is a remote dentry, to do the reintegration. While in the
'rename' code when traversing the path it will trigger to call the
'dn->link_remote()', which later will fire a new stray dentry
reintegration.

The problem is if the first 'rename' request is retried several
times, and in each time it will fire a new reintegration, which
makes no sense and maybe blocked for a very long time dues to some
reasons and then will be reported as slow request warning.

Fixes: https://tracker.ceph.com/issues/62702
Signed-off-by: Xiubo Li <xiubli@redhat.com>
  • Loading branch information
lxbsz committed Sep 19, 2023
1 parent 59c7f56 commit 0983390
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/mds/CDentry.h
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,8 @@ class CDentry : public MDSCacheObject, public LRUObject, public Counter<CDentry>
mempool::mds_co::map<client_t,ClientLease*> client_lease_map;
std::map<int, std::unique_ptr<BatchOp>> batch_ops;

ceph_tid_t reintegration_reqid = 0;


protected:
friend class Migrator;
Expand Down
2 changes: 2 additions & 0 deletions src/mds/MDSRank.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,10 @@ struct MDSMetaRequest {
explicit MDSMetaRequest(int o, CDentry *d, ceph_tid_t t) :
op(o), dentry(d), tid(t) {
dentry->get(CDentry::PIN_PURGING);
dentry->reintegration_reqid = tid;
}
~MDSMetaRequest() {
dentry->reintegration_reqid = 0;
dentry->put(CDentry::PIN_PURGING);
}

Expand Down
12 changes: 12 additions & 0 deletions src/mds/StrayManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -673,6 +673,12 @@ void StrayManager::reintegrate_stray(CDentry *straydn, CDentry *rdn)
{
dout(10) << __func__ << " " << *straydn << " to " << *rdn << dendl;

if (straydn->reintegration_reqid) {
dout(20) << __func__ << ": stray dentry " << *straydn
<< " is already under reintegrating" << dendl;
return;
}

logger->inc(l_mdc_strays_reintegrated);

// rename it to remote linkage .
Expand All @@ -698,6 +704,12 @@ void StrayManager::migrate_stray(CDentry *dn, mds_rank_t to)
{
dout(10) << __func__ << " " << *dn << " to mds." << to << dendl;

if (dn->reintegration_reqid) {
dout(20) << __func__ << ": stray dentry " << *dn
<< " is already under migrating" << dendl;
return;
}

logger->inc(l_mdc_strays_migrated);

// rename it to another mds.
Expand Down

0 comments on commit 0983390

Please sign in to comment.