From 9f6ddc90d5a2162ecfecbdb5f5ed5bd9f71cc65f Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Wed, 7 Jan 2026 08:27:06 +0100 Subject: [PATCH] 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 Signed-off-by: Anna Schumaker --- fs/nfs/delegation.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c index 762d79ee58e30..a64c30efa1a3e 100644 --- a/fs/nfs/delegation.c +++ b/fs/nfs/delegation.c @@ -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; } -- 2.47.3