Skip to content

Commit

Permalink
Merge PR ceph#52522 into main
Browse files Browse the repository at this point in the history
* refs/pull/52522/head:
	mds: drop locks and retry when lock set changes

Reviewed-by: Venky Shankar <[email protected]>
  • Loading branch information
vshankar committed Aug 31, 2023
2 parents 4e021a0 + b5719ac commit e1adcae
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/mds/Server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4119,6 +4119,24 @@ void Server::handle_client_getattr(MDRequestRef& mdr, bool is_lookup)
} else if (ref->filelock.is_stable() ||
ref->filelock.get_num_wrlocks() > 0 ||
!ref->filelock.can_read(mdr->get_client())) {
/* Since we're taking advantage of an optimization here:
*
* We cannot suddenly, due to a changing condition, add this filelock as
* it can cause lock-order deadlocks. In this case, that condition is the
* lock state changes between request retries. If that happens, we need
* to check if we've acquired the other locks in this vector. If we have,
* then we need to drop those locks and retry.
*/
if (mdr->is_rdlocked(&ref->linklock) ||
mdr->is_rdlocked(&ref->authlock) ||
mdr->is_rdlocked(&ref->xattrlock)) {
/* start over */
dout(20) << " dropping locks and restarting request because filelock state change" << dendl;
mds->locker->drop_locks(mdr.get());
mdr->drop_local_auth_pins();
mds->queue_waiter(new C_MDS_RetryRequest(mdcache, mdr));
return;
}
lov.add_rdlock(&ref->filelock);
mdr->locking_state &= ~MutationImpl::ALL_LOCKED;
}
Expand Down

0 comments on commit e1adcae

Please sign in to comment.