]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
NFS: use a local RCU critical section in nfs_start_delegation_return
authorChristoph Hellwig <hch@lst.de>
Wed, 7 Jan 2026 07:27:11 +0000 (08:27 +0100)
committerAnna Schumaker <anna.schumaker@oracle.com>
Tue, 20 Jan 2026 19:49:47 +0000 (14:49 -0500)
Nested RCU critical sections are fine and very cheap.  Have a local one
in nfs_start_delegation_return so that the function is self-contained
and to prepare for simplifying the callers.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Anna Schumaker <anna.schumaker@oracle.com>
fs/nfs/delegation.c

index a3996bd702364289351e61f3a9673d51e4643337..09e0d3732fda2d216a087a5a5ac309ef7b844151 100644 (file)
@@ -309,11 +309,13 @@ nfs_start_delegation_return(struct nfs_inode *nfsi)
        struct nfs_delegation *delegation;
        bool return_now = false;
 
-       lockdep_assert_in_rcu_read_lock();
-
+       rcu_read_lock();
        delegation = rcu_dereference(nfsi->delegation);
-       if (!delegation || !refcount_inc_not_zero(&delegation->refcount))
+       if (!delegation || !refcount_inc_not_zero(&delegation->refcount)) {
+               rcu_read_unlock();
                return NULL;
+       }
+       rcu_read_unlock();
 
        spin_lock(&delegation->lock);
        if (delegation->inode &&
@@ -767,10 +769,7 @@ int nfs4_inode_return_delegation(struct inode *inode)
        struct nfs_delegation *delegation;
        int err;
 
-       rcu_read_lock();
        delegation = nfs_start_delegation_return(nfsi);
-       rcu_read_unlock();
-
        if (!delegation)
                return 0;