NFSv4.2/pNFS: fix applacation get old size of file

Quan Quan6 Wang <[email protected]> Wed, 29 Jul 2026 02:07:00 +0000
Newsgroups gmane.linux.nfs,gmane.linux.kernel
Message-ID <KL1PR0302MB52028CB56AB48DC0DEAA4A9786CA2@KL1PR0302MB5202.apcprd03.prod.outlook.com>
From 5dca30906b0f705d6a1593e2a0c75bb044ef0dcc Mon Sep 17 00:00:00 2001
From: wangquan6 mailto:[email protected]
Date: Tue, 28 Jul 2026 06:48:15 +0000
Subject: [PATCH] NFSv4.2/pNFS: fix applacation get old size of file

it happened when call nfs_lookup_revalidate_dentry
between pnfs_set_layoutcommit and nfs4_layoutcommit_release

Signed-off-by: Quan Wang=A0 mailto:[email protected]
---
fs/nfs/inode.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
index 5bcd4027d..c07a046ff 100644
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -2381,7 +2381,8 @@ static int nfs_update_inode(struct inode *inode, stru=
ct nfs_fattr *fattr)
=A0=A0=A0 if (fattr->valid & NFS_ATTR_FATTR_SIZE) {
=A0=A0=A0=A0=A0=A0=A0 new_isize =3D nfs_size_to_loff_t(fattr->size);
=A0=A0=A0=A0=A0=A0=A0 cur_isize =3D i_size_read(inode);
-=A0=A0=A0=A0=A0=A0 if (new_isize !=3D cur_isize && !have_delegation) {
+=A0=A0=A0=A0=A0=A0 if (new_isize !=3D cur_isize && !have_delegation &&
+=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 !pnfs_layoutcommit_outstanding(inode)) {
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 /* Do we perhaps have any outstanding wri=
tes, or has
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 * the file grown beyond our last write=
? */
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 if (!nfs_have_writebacks(inode) || new_is=
ize > cur_isize) {
--=20
2.34.1