From: Chuck Lever <cel@kernel.org>
To: NeilBrown <neil@brown.name>, Jeff Layton <jlayton@kernel.org>,
Olga Kornievskaia <okorniev@redhat.com>,
Dai Ngo <dai.ngo@oracle.com>, Tom Talpey <tom@talpey.com>
Cc: <linux-nfs@vger.kernel.org>
Subject: [PATCH v1 4/7] nfsd: keep spliced pages below rq_next_page when a READ fails
Date: Sun, 4 Oct 2026 15:40:26 -0400 [thread overview]
Message-ID: <20261004194029.10714-5-cel@kernel.org> (raw)
In-Reply-To: <20261004194029.10714-1-cel@kernel.org>
nfsd_splice_actor() replaces rq_respages entries with page cache
pages and advances rq_next_page past them. When
svc_encode_result_payload() then fails, nfsd4_encode_splice_read()
zeroes page_len, and nfsd4_encode_operation() computes rq_next_page
from the empty payload. svc_rqst_release_pages() and svc_alloc_arg()
handle only the entries below rq_next_page, so the spliced pages
stay in rq_respages. A later reply that encodes into those entries
overwrites the page cache of the file that was read.
svc_rdma_result_payload() returns -E2BIG when the READ payload is
larger than the Write chunk the client provided, so an NFS/RDMA
client can trigger the failure.
When an operation fails, do not move rq_next_page backward. A
successful operation still sets rq_next_page from the payload
length, because a short read through nfsd_iter_read() leaves
rq_next_page past pages the reply does not use.
Fixes: 76e5492b161f ("NFSD: Invoke svc_encode_result_payload() in "read" NFSD encoders")
Signed-off-by: Chuck Lever <cel@kernel.org>
---
fs/nfsd/nfs4xdr.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
index b86d181b58c3..d9417ebbe9db 100644
--- a/fs/nfsd/nfs4xdr.c
+++ b/fs/nfsd/nfs4xdr.c
@@ -6804,7 +6804,14 @@ nfsd4_encode_operation(struct nfsd4_compoundres *resp, struct nfsd4_op *op)
next_page = xdr->buf->pages +
DIV_ROUND_UP(xdr->buf->page_base + xdr->buf->page_len,
PAGE_SIZE);
- rqstp->rq_next_page = min(next_page, rqstp->rq_page_end);
+ next_page = min(next_page, rqstp->rq_page_end);
+ /*
+ * A failed splice read leaves page cache pages in rq_respages
+ * above the truncated payload. Keep them below rq_next_page so
+ * that svc_rqst_release_pages() releases them.
+ */
+ if (!op->status || next_page > rqstp->rq_next_page)
+ rqstp->rq_next_page = next_page;
}
/**
--
2.55.0
next prev parent reply other threads:[~2026-10-04 19:40 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-04 19:40 [PATCH v1 0/7] NFSD short subjects Chuck Lever
2026-10-04 19:40 ` [PATCH v1 1/7] nfsd: use direct I/O only for the last operation in a COMPOUND Chuck Lever
2026-10-04 19:40 ` [PATCH v1 2/7] nfsd: account for page_base when advancing rq_next_page Chuck Lever
2026-10-04 19:40 ` [PATCH v1 3/7] nfsd: locate the READ sink page from the reply buffer Chuck Lever
2026-10-04 19:40 ` Chuck Lever [this message]
2026-10-04 19:40 ` [PATCH v1 5/7] nfsd: remove unreachable cancel of the layout fence work Chuck Lever
2026-10-04 19:40 ` [PATCH v1 6/7] sunrpc: preserve rq_daddrlen across request deferral Chuck Lever
2026-10-04 19:40 ` [PATCH v1 7/7] sunrpc: assign RQ_LOCAL from the transport on every receive Chuck Lever
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261004194029.10714-5-cel@kernel.org \
--to=cel@kernel.org \
--cc=dai.ngo@oracle.com \
--cc=jlayton@kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=neil@brown.name \
--cc=okorniev@redhat.com \
--cc=tom@talpey.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox