Skip to content

Commit 2fdbc20

Browse files
neilbrownTrond Myklebust
authored andcommitted
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>
1 parent 0b81371 commit 2fdbc20

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

fs/nfs/pnfs.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1999,6 +1999,14 @@ pnfs_update_layout(struct inode *ino,
19991999
}
20002000

20012001
lookup_again:
2002+
if (!nfs4_valid_open_stateid(ctx->state)) {
2003+
trace_pnfs_update_layout(ino, pos, count,
2004+
iomode, lo, lseg,
2005+
PNFS_UPDATE_LAYOUT_INVALID_OPEN);
2006+
lseg = ERR_PTR(-EIO);
2007+
goto out;
2008+
}
2009+
20022010
lseg = ERR_PTR(nfs4_client_recover_expired_lease(clp));
20032011
if (IS_ERR(lseg))
20042012
goto out;

0 commit comments

Comments
 (0)