From: Trond Myklebust Date: Tue, 27 Aug 2019 00:41:16 +0000 (-0400) Subject: NFSv2: Fix eof handling X-Git-Tag: v4.9.194~19 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bc94dcfbc58199158f71547d06dfb003fa3c1e7a;p=thirdparty%2Fkernel%2Fstable.git NFSv2: Fix eof handling [ Upstream commit 71affe9be45a5c60b9772e1b2701710712637274 ] If we received a reply from the server with a zero length read and no error, then that implies we are at eof. Signed-off-by: Trond Myklebust Signed-off-by: Sasha Levin --- diff --git a/fs/nfs/proc.c b/fs/nfs/proc.c index b7bca83039895..f3e8bcbd29a09 100644 --- a/fs/nfs/proc.c +++ b/fs/nfs/proc.c @@ -588,7 +588,8 @@ static int nfs_read_done(struct rpc_task *task, struct nfs_pgio_header *hdr) /* Emulate the eof flag, which isn't normally needed in NFSv2 * as it is guaranteed to always return the file attributes */ - if (hdr->args.offset + hdr->res.count >= hdr->res.fattr->size) + if ((hdr->res.count == 0 && hdr->args.count > 0) || + hdr->args.offset + hdr->res.count >= hdr->res.fattr->size) hdr->res.eof = 1; } return 0;