Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=165.173.182.16 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796185752; b=VgK064wXkwXG7odEN6GoYFQsoBYusoDHkn0kZ3yNOlRZIlDiNAYXW3u3c9GB6Ka9KZkQ z4XxuFfsYwkTlPqzTQl4rD3ZEi5+xy0mdAQIVP4yJobnY7SW2UTq2zhol48Pgo7W/cLqQ uql+p+7tvfE4onW1868+XUKCShDTo4ifdN33yEl4hzf6sG7sW29lQD0bM1WNjXHrTqBTq X3dxLddXGe6jUsuB98+EvrInjE214AfEipzfKKu58UNn03LxfyVUDatIUqqjuNRozDTLU DgPMKUsqmMKsaZ24F2ZVb8RasnWJ8K64m4i9ZG/GGNjALtUICYYXqq6G8RJa49XVQ+Q== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796185752; h=DMARC-Filter:DKIM-Signature:Received:From:To:Cc:Subject:Date: Message-ID:X-Mailer:MIME-Version:Content-Transfer-Encoding: X-ZohoMailClient; bh=KAmSWFH+vSLGewvRHIJrbWxj/RtkNq397Z5PEpM+gVA=; b=2jPmuRiKc97LhGQ6cgSh+YJ9y5HJ+sDVQ46xHUz30H900a28M7o0lcs42YGlSO40A/KF 2ob4MdVXsrelK0efqOFnwcI6IE/dpDR+6gQH3sJUmH6u2fg/Jsohh4EIaoPU9BoOuYdHl 4hLOcDkfc0poe1w1ISSWHo87JhI0flW5cx+gmzrrmDUNk7eDfQnQ+hsIgfQNPQ4/iaVaC 1NdTGNb6FnxhpvWaKHnsHRkLXEjQjB9epRF6zKFpnZe3Jvosr/ZJ0Md91GY3JGdd8R3Bu hiW1KPoRyvTkFJc/SuT6Q+FPBYZ6WORGpzTwe0xGavsp7A5zzyIIGrumH0ih+d0MMdA== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none header.from=laveeshbansal.com; spf=pass smtp.mailfrom=laveeshbansal.com; dkim=pass header.d=laveeshbansal.com header.i=@laveeshbansal.com header.a=rsa-sha256 header.s=zoho header.b=MAb8+x04; arc=pass header.oldest-pass=0 smtp.remote-ip=165.173.182.16 Received: from sender5-op-o16.zoho.com (sender5-op-o16.zoho.com [165.173.182.16]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 14AC7606A31A for ; Wed, 2 Dec 2026 04:29:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 14AC7606A31A Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=laveeshbansal.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=laveeshbansal.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=laveeshbansal.com header.i=@laveeshbansal.com header.a=rsa-sha256 header.s=zoho header.b=MAb8+x04 ARC-Seal: i=1; a=rsa-sha256; t=1796185743; cv=none; d=zohomail.com; s=zohoarc; b=nkidJf6ApnSqRBB5osjb+UvmcUcQFjKus1LzpBKkF13qH4P6+DiBR2H+loMtxQA6dGwscU6IJLzrU61E/E3OmRkP+/1GVu28avw1GmCqIzeNR8UQ6Sev77oVztCgot155MOMT64uPE89dt4v+yr7S0UnqOBd8f+gzGZNgNT28do= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1796185743; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:MIME-Version:Message-ID:Subject:Subject:To:To:Message-Id:Reply-To; bh=KAmSWFH+vSLGewvRHIJrbWxj/RtkNq397Z5PEpM+gVA=; b=j/TLZ+lyFIJII6WeZDFWS70ZJc1Izb9ng5Kq7tdhhA8+jtrSEOJkZli0x35hXemTpUQ4RHKhJ4FfBjhOiq7pp5cUvi0Sf6bExdDgvEc0TXnbZ93N/conjEoU1Xj8djN/S7hqfl6kjSGbowtJhn2V9C48qtPjWmzZ9/teNdC/Ziw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=laveeshbansal.com; spf=pass smtp.mailfrom=laveeshb@laveeshbansal.com; dmarc=pass header.from= DKIM-Signature: a=rsa-sha256; b=MAb8+x04ctIJqT0bfAijvDWsR2GGoYo0d8HeFRQO4LeRVSJUXCVvHbplY0kRsdAr8EOoosZeU8myiYQqX9sQLIP3Ga1Scg7pmGijwNA90+mZgYwfuUveNZSz61Qu3w5ajAd42EzgsMZi/d3UrtTRv1dzp7EYBtCLOqjTIQQ5S/s=; c=relaxed/relaxed; s=zoho; d=laveeshbansal.com; v=1; bh=KAmSWFH+vSLGewvRHIJrbWxj/RtkNq397Z5PEpM+gVA=; h=Content-Description:Content-ID:Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Resent-Sender:Resent-Cc:Resent-Date:Resent-To:Reply-To:Resent-Message-ID:Resent-From:Sender:Subject:To:Date:From:Message-Id:Reply-To:Subject:To:Cc; Received: by smtp.zohomail.com with SMTPS id 1796185739767856.7764878667625; Tue, 1 Dec 2026 20:28:59 -0800 (PST) From: Laveesh Bansal To: Trond Myklebust , Anna Schumaker Cc: Nurullah Morshed , Dave Wysochanski , David Howells , Paulo Alcantara , linux-nfs@vger.kernel.org, netfs@lists.linux.dev, linux-fsdevel@vger.kernel.org Subject: [PATCH] NFS: count all bytes of a retried READ in netfs reads Date: Tue, 1 Dec 2026 20:28:57 -0800 Message-ID: <20261202042857.29113-1-laveeshb@laveeshbansal.com> X-Mailer: git-send-email 2.54.0 X-Mailing-List: netfs@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-ZohoMailClient: External 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