Linux NFS development
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Trond Myklebust <trondmy@kernel.org>, Anna Schumaker <anna@kernel.org>
Cc: Chris Mason <clm@meta.com>, linux-nfs@vger.kernel.org
Subject: [PATCH 6/7] NFS: simplify error handling in nfs_end_delegation_return
Date: Wed, 28 Jan 2026 05:46:08 +0100	[thread overview]
Message-ID: <20260128044706.556046-7-hch@lst.de> (raw)
In-Reply-To: <20260128044706.556046-1-hch@lst.de>

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>
---
 fs/nfs/delegation.c | 23 ++++++++++-------------
 1 file changed, 10 insertions(+), 13 deletions(-)

diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c
index cf90aa7f922a..cff49a934c9e 100644
--- a/fs/nfs/delegation.c
+++ b/fs/nfs/delegation.c
@@ -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;
 }
 
-- 
2.47.3


  parent reply	other threads:[~2026-01-28  4:47 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-28  4:46 delayed delegation return handling fix Christoph Hellwig
2026-01-28  4:46 ` [PATCH 1/7] NFS: return void from nfs4_inode_make_writeable Christoph Hellwig
2026-01-28  4:46 ` [PATCH 2/7] NFS: return void from ->return_delegation Christoph Hellwig
2026-01-28  4:46 ` [PATCH 3/7] NFS: use bool for the issync argument to nfs_end_delegation_return Christoph Hellwig
2026-01-28  4:46 ` [PATCH 4/7] NFS: remove the delegation == NULL check in nfs_end_delegation_return Christoph Hellwig
2026-01-28  4:46 ` [PATCH 5/7] NFS: fold nfs_abort_delegation_return into nfs_end_delegation_return Christoph Hellwig
2026-01-28  4:46 ` Christoph Hellwig [this message]
2026-01-28  4:46 ` [PATCH 7/7] NFS: fix delayed delegation return handling Christoph Hellwig
2026-01-28 19:15 ` delayed delegation return handling fix Chris Mason

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260128044706.556046-7-hch@lst.de \
    --to=hch@lst.de \
    --cc=anna@kernel.org \
    --cc=clm@meta.com \
    --cc=linux-nfs@vger.kernel.org \
    --cc=trondmy@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox