From: Sagi Grimberg <sagi@grimberg.me>
To: linux-nfs@vger.kernel.org,
Trond Myklebust <trond.myklebust@hammerspace.com>,
Anna Schumaker <anna@kernel.org>,
Jeff Layton <jlayton@kernel.org>
Subject: [PATCH rfc] NFSv4: Keep delegation post REMOVE in case server supports preserved-unliked
Date: Tue, 28 Apr 2026 11:24:54 +0300 [thread overview]
Message-ID: <20260428082454.26045-1-sagi@grimberg.me> (raw)
If the server returns NFS4_OPEN_RESULT_PRESERVE_UNLINKED, it means that
the file handle is kept alive for as long as the file is opened (or its
delegation is held). Hence, we can skip re-opening the file and returning
the delegation in this case.
Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
---
fs/nfs/nfs4proc.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index 91bcf67bd743..129424eacf99 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -4921,10 +4921,17 @@ static int nfs4_proc_remove(struct inode *dir, struct dentry *dentry)
int err;
if (inode) {
- if (inode->i_nlink == 1)
- nfs4_inode_return_delegation(inode);
- else
+ /*
+ * nlink > 1 or server supports NFS_INO_PRESERVE_UNLINKED
+ * the inode is not going away. we're promised to keep the
+ * inode alive past REMOVE for as long as any client reference
+ * remains. So we can keep the delegation around.
+ */
+ if (inode->i_nlink > 1 ||
+ test_bit(NFS_INO_PRESERVE_UNLINKED, &NFS_I(inode)->flags))
nfs4_inode_make_writeable(inode);
+ else
+ nfs4_inode_return_delegation(inode);
}
do {
err = _nfs4_proc_remove(dir, &dentry->d_name, NF4REG);
--
2.43.0
reply other threads:[~2026-04-28 8:24 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20260428082454.26045-1-sagi@grimberg.me \
--to=sagi@grimberg.me \
--cc=anna@kernel.org \
--cc=jlayton@kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=trond.myklebust@hammerspace.com \
/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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).