summaryrefslogtreecommitdiffstats
path: root/fs/nfs/pnfs.c
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2024-02-28 11:24:53 +1100
committerTrond Myklebust <trond.myklebust@hammerspace.com>2024-03-09 09:14:51 -0500
commit2fdbc20036acda9e5694db74a032d3c605323005 (patch)
tree8dc77e3e36b3cefb0c8ab3d1701d827ebd3a5eb8 /fs/nfs/pnfs.c
parent0b81371d3c6b849bfde9f478bfe70661759cc018 (diff)
downloadlinux-2fdbc20036acda9e5694db74a032d3c605323005.tar.gz
linux-2fdbc20036acda9e5694db74a032d3c605323005.tar.bz2
linux-2fdbc20036acda9e5694db74a032d3c605323005.zip
NFS: avoid infinite loop in pnfs_update_layout.
If pnfsd_update_layout() is called on a file for which recovery has failed it will enter a tight infinite loop. NFS_LAYOUT_INVALID_STID will be set, nfs4_select_rw_stateid() will return -EIO, and nfs4_schedule_stateid_recovery() will do nothing, so nfs4_client_recover_expired_lease() will not wait. So the code will loop indefinitely. Break the loop by testing the validity of the open stateid at the top of the loop. Signed-off-by: NeilBrown <neilb@suse.de> Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Diffstat (limited to 'fs/nfs/pnfs.c')
-rw-r--r--fs/nfs/pnfs.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c
index 0c0fed1ecd0b..a5cc6199127f 100644
--- a/fs/nfs/pnfs.c
+++ b/fs/nfs/pnfs.c
@@ -1999,6 +1999,14 @@ pnfs_update_layout(struct inode *ino,
}
lookup_again:
+ if (!nfs4_valid_open_stateid(ctx->state)) {
+ trace_pnfs_update_layout(ino, pos, count,
+ iomode, lo, lseg,
+ PNFS_UPDATE_LAYOUT_INVALID_OPEN);
+ lseg = ERR_PTR(-EIO);
+ goto out;
+ }
+
lseg = ERR_PTR(nfs4_client_recover_expired_lease(clp));
if (IS_ERR(lseg))
goto out;