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 15, 2023
1 parent bb9f4e7 commit 36adf82
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
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 @@ -161,8 +161,10 @@ struct MDSMetaRequest {
op(o), stray_dentry(d), tid(t) {

stray_dentry->get(CDentry::PIN_PURGING);
stray_dentry->reintegration_reqid = tid;
}
~MDSMetaRequest() {
stray_dentry->reintegration_reqid = 0;
stray_dentry->put(CDentry::PIN_PURGING);
}

Expand Down
8 changes: 7 additions & 1 deletion src/mds/StrayManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,13 @@ void StrayManager::eval_remote(CDentry *remote_dn)
CDentry *primary_dn = in->get_projected_parent_dn();
ceph_assert(primary_dn != NULL);
if (primary_dn->get_dir()->get_inode()->is_stray()) {
_eval_stray_remote(primary_dn, remote_dn);
if (!primary_dn->reintegration_reqid) {
_eval_stray_remote(primary_dn, remote_dn);
} else {
dout(20) << __func__
<< ": inode's primary is already under reintegrating/migrating"
<< dendl;
}
} else {
dout(20) << __func__ << ": inode's primary dn not stray" << dendl;
}
Expand Down

0 comments on commit 36adf82

Please sign in to comment.