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

From: wangquan6 mailto : wangquan6

Date: Tue Jul 28 2026 - 02:48:15 EST


it happened when call nfs_lookup_revalidate_dentry
between pnfs_set_layoutcommit and nfs4_layoutcommit_release

Signed-off-by: Quan Wang=A0 mailto:wangquan6@xxxxxxxxxx
---
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