From: Dai Ngo <dai.ngo@oracle.com>
To: trondmy@kernel.org, anna@kernel.org
Cc: linux-nfs@vger.kernel.org
Subject: [PATCH 1/1] Don't always trust server inode size while client holds write delegation
Date: Wed, 1 Apr 2026 11:52:37 -0700 [thread overview]
Message-ID: <20260401185322.2691848-1-dai.ngo@oracle.com> (raw)
With a write delegation, the server permits the client to buffer writes
and associated metadata updates (including file size changes) locally and
defer propagating them to the server. As a result, the server-reported
GETATTR size may legitimately lag behind the client’s cached size for the
duration of the delegation, so it must not be treated as authoritative.
This patch modifies nfs_wcc_update_inode to update the cached inode size
only when the client does not hold a write delegation or the cache_validity
of the nfs_inode has the NFS_INO_INVALID_SIZE bit set.
Signed-off-by: Dai Ngo <dai.ngo@oracle.com>
---
fs/nfs/inode.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
index 4786343eeee0..21161ebbd953 100644
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -1649,8 +1649,11 @@ static void nfs_wcc_update_inode(struct inode *inode, struct nfs_fattr *fattr)
&& (fattr->valid & NFS_ATTR_FATTR_SIZE)
&& i_size_read(inode) == nfs_size_to_loff_t(fattr->pre_size)
&& !nfs_have_writebacks(inode)) {
- trace_nfs_size_wcc(inode, fattr->size);
- i_size_write(inode, nfs_size_to_loff_t(fattr->size));
+ if ((!nfs_have_write_delegation(inode)) ||
+ (NFS_I(inode)->cache_validity & NFS_INO_INVALID_SIZE)) {
+ trace_nfs_size_wcc(inode, fattr->size);
+ i_size_write(inode, nfs_size_to_loff_t(fattr->size));
+ }
}
}
--
2.47.3
next reply other threads:[~2026-04-01 18:53 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-01 18:52 Dai Ngo [this message]
2026-04-13 22:19 ` [PATCH 1/1] Don't always trust server inode size while client holds write delegation Trond Myklebust
2026-04-16 1:43 ` Dai Ngo
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=20260401185322.2691848-1-dai.ngo@oracle.com \
--to=dai.ngo@oracle.com \
--cc=anna@kernel.org \
--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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).