A file read with fsc from a server that sends short READ replies can come back with its end zeroed. No error is returned. nfs_readpage_retry() resends the rest of a short READ on the same header and resets res.count. Commit 000dbe0bec05 ("NFS: Convert buffered read paths to use netfs when fscache is enabled") added nfs_netfs_read_completion(). It adds only the last reply to the bytes transferred. Add hdr->good_bytes instead. nfs_read_completion() already uses it as the number of valid bytes in the header. Fixes: 000dbe0bec05 ("NFS: Convert buffered read paths to use netfs when fscache is enabled") Cc: stable@vger.kernel.org # 6.4+ Reported-by: Nurullah Morshed Closes: https://lore.kernel.org/r/YQBP288MB016467ACB8048B62A153F00CBB642@YQBP288MB0164.CANP288.PROD.OUTLOOK.COM Signed-off-by: Laveesh Bansal --- Notes: I tested on arm64 and x86_64 (QEMU) with KASAN and lockdep: - Changed nfsd to cap READ replies at 32 KiB. - Read 100 files with known MD5s over NFSv3 with fsc. - Without the patch: 77 files on arm64 and 70 on x86_64 came back with a zeroed tail. - With the patch: 0 files on either arch showed the issue. - Same result with NFSv4 and with random reply sizes. I used an LLM for the research, the test runs and the first draft of this patch. I did the final changes and review myself. fs/nfs/fscache.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/nfs/fscache.c b/fs/nfs/fscache.c index 9b7fdad4a9201..8108e53addb8f 100644 --- a/fs/nfs/fscache.c +++ b/fs/nfs/fscache.c @@ -374,7 +374,7 @@ void nfs_netfs_read_completion(struct nfs_pgio_header *hdr) if (hdr->error) netfs->error = hdr->error; else - atomic64_add(hdr->res.count, &netfs->transferred); + atomic64_add(hdr->good_bytes, &netfs->transferred); nfs_netfs_put(netfs); hdr->netfs = NULL; base-commit: 3e19991734326332c736e24c9b47b2cffb8f9e42 -- 2.43.0