]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
NFS: simplify error handling in nfs_end_delegation_return
authorChristoph Hellwig <hch@lst.de>
Wed, 28 Jan 2026 04:46:08 +0000 (05:46 +0100)
committerAnna Schumaker <anna.schumaker@oracle.com>
Fri, 30 Jan 2026 21:49:15 +0000 (16:49 -0500)
Drop the pointless delegation->lock held over setting multiple
atomic bits in different structures, and use separate labels
for the delay vs abort cases.

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

index cf90aa7f922a0e25efec325997931e771b96ff5e..cff49a934c9e4da815c7858f63aa0a2d9c110953 100644 (file)
@@ -570,30 +570,27 @@ static int nfs_end_delegation_return(struct inode *inode,
                        break;
                err = nfs_delegation_claim_opens(inode, &delegation->stateid,
                                delegation->type);
-               if (!issync || err != -EAGAIN)
+               if (!err)
                        break;
+               if (err != -EAGAIN)
+                       goto abort;
+               if (!issync)
+                       goto delay;
+
                /*
                 * Guard against state recovery
                 */
                err = nfs4_wait_clnt_recover(server->nfs_client);
        }
 
-       if (err)
-               goto abort;
-
 out_return:
        return nfs_do_return_delegation(inode, delegation, issync);
+delay:
+       set_bit(NFS_DELEGATION_RETURN_DELAYED, &delegation->flags);
+       set_bit(NFS4SERV_DELEGRETURN_DELAYED, &server->delegation_flags);
+       set_bit(NFS4CLNT_DELEGRETURN_DELAYED, &server->nfs_client->cl_state);
 abort:
-       spin_lock(&delegation->lock);
        clear_bit(NFS_DELEGATION_RETURNING, &delegation->flags);
-       if (err == -EAGAIN) {
-               set_bit(NFS_DELEGATION_RETURN_DELAYED, &delegation->flags);
-               set_bit(NFS4SERV_DELEGRETURN_DELAYED,
-                       &server->delegation_flags);
-               set_bit(NFS4CLNT_DELEGRETURN_DELAYED,
-                       &server->nfs_client->cl_state);
-       }
-       spin_unlock(&delegation->lock);
        return err;
 }