]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
NFS: move the deleg_cur check out of nfs_detach_delegation_locked
authorChristoph Hellwig <hch@lst.de>
Wed, 7 Jan 2026 07:27:06 +0000 (08:27 +0100)
committerAnna Schumaker <anna.schumaker@oracle.com>
Tue, 20 Jan 2026 19:49:46 +0000 (14:49 -0500)
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>
fs/nfs/delegation.c

index 762d79ee58e306bda6a7477296ea6c11b960f98c..a64c30efa1a3e55bfbb72681ee54f39161753b13 100644 (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;
 }