NFS: Don't loop forever in nfs_do_recoalesce()
authorTrond Myklebust <trond.myklebust@hammerspace.com>
Sat, 26 Mar 2022 01:51:03 +0000 (21:51 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 8 Apr 2022 12:06:30 +0000 (14:06 +0200)
commit6d12ce1468e18033e77d46a4f5c97522c2c90aa5
tree7b594899e8ec20ba8341d0c88c9d1579217200c9
parentf1b21d17ba19131c1af32cd1dbcb8b0e34f281eb
NFS: Don't loop forever in nfs_do_recoalesce()

[ Upstream commit d02d81efc7564b4d5446a02e0214a164cf00b1f3 ]

If __nfs_pageio_add_request() fails to add the request, it will return
with either desc->pg_error < 0, or mirror->pg_recoalesce will be set, so
we are guaranteed either to exit the function altogether, or to loop.

However if there is nothing left in mirror->pg_list to coalesce, we must
exit, so make sure that we clear mirror->pg_recoalesce every time we
loop.

Reported-by: Olga Kornievskaia <aglo@umich.edu>
Fixes: 70536bf4eb07 ("NFS: Clean up reset of the mirror accounting variables")
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/nfs/pagelist.c