NFS: count all bytes of a retried READ in netfs reads
Subsystems (4)
PATCH 1/1 NFS: count all bytes of a retried READ in netfs reads
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.
---
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(-)
fs/nfs/fscache.c +1 -1
@@ -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
Signature · 1 line
2.43.0