NFS: move the deleg_cur check out of nfs_detach_delegation_locked

nfs_inode_set_delegation as the only direct caller of
nfs_detach_delegation_locked already check this under cl_lock, so
don't repeat it.

Replace the lockdep coverage for the lock that was implicitly provided by
the rcu_dereference_protected call that is removed with an explicit
lockdep assert to keep the coverage.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Anna Schumaker <anna.schumaker@oracle.com>
This commit is contained in:
Christoph Hellwig 2026-01-07 08:27:06 +01:00 committed by Anna Schumaker
parent 8f7e0b8080
commit 9f6ddc90d5

View File

@ -350,15 +350,10 @@ nfs_detach_delegation_locked(struct nfs_inode *nfsi,
struct nfs_delegation *delegation,
struct nfs_client *clp)
{
struct nfs_delegation *deleg_cur =
rcu_dereference_protected(nfsi->delegation,
lockdep_is_held(&clp->cl_lock));
lockdep_assert_held(&clp->cl_lock);
trace_nfs4_detach_delegation(&nfsi->vfs_inode, delegation->type);
if (delegation != deleg_cur)
return false;
spin_lock(&delegation->lock);
if (!delegation->inode) {
spin_unlock(&delegation->lock);
@ -378,10 +373,14 @@ static bool nfs_detach_delegation(struct nfs_inode *nfsi,
struct nfs_server *server)
{
struct nfs_client *clp = server->nfs_client;
bool ret;
struct nfs_delegation *deleg_cur;
bool ret = false;
spin_lock(&clp->cl_lock);
ret = nfs_detach_delegation_locked(nfsi, delegation, clp);
deleg_cur = rcu_dereference_protected(nfsi->delegation,
lockdep_is_held(&clp->cl_lock));
if (delegation == deleg_cur)
ret = nfs_detach_delegation_locked(nfsi, delegation, clp);
spin_unlock(&clp->cl_lock);
return ret;
}