From: Chuck Lever <cel@kernel.org>
To: NeilBrown <neil@brown.name>
Cc: Mike Snitzer <snitzer@kernel.org>,
Jeff Layton <jlayton@kernel.org>,
Olga Kornievskaia <okorniev@redhat.com>,
Dai Ngo <dai.ngo@oracle.com>, Tom Talpey <tom@talpey.com>,
linux-nfs@vger.kernel.org, Chuck Lever <chuck.lever@oracle.com>
Subject: Re: [PATCH v3 3/3] NFSD: Implement NFSD_IO_DIRECT for NFS READ
Date: Wed, 24 Sep 2025 14:56:53 -0400 [thread overview]
Message-ID: <5b82341d-bec2-4c99-826c-0fa8a7b49268@kernel.org> (raw)
In-Reply-To: <175869903827.1696783.17181184352630252525@noble.neil.brown.name>
On 9/24/25 12:30 AM, NeilBrown wrote:
> nfsd4_encode_readv() calls xdr_reserve_space_vec() passing maxcount from
> the READ request. The maxcount is passed to xdr_reserve_space()
> repeatedly (one page at a time) where it is added to xdr->buf->page_len
> (where xdr is ->rq_res_stream and xdr->buf is rq_res).
>
> So the result is often that rq_res.page_len will be maxcount.
>
> Then nfsd4_encode_readv() calls nfsd_iter_read() which, with this patch,
> will test rq_res.page_len, which will always be non-zero.
> So that isn't what we want.
>
> (after the read, nfsd4_encode_readv() will call xdr_truncate_encode()
> which will reduce ->page_len based on how much was read).
>
> Then nfsd4_encode_readv() calls nfsd_iter_read().
>
> I don't think we can use ->page_len to determine if it is safe to use
> nfsd_direct_read().
Agreed.
> The conditions where nfsd_direct_read() is safe are
> similar to the conditions where nfsd_splice_read() is safe. Maybe we
> should use similar code.
That seems to be this bit of logic at the tail of
nfsd4_decode_compound() ?
argp->splice_ok = nfsd_read_splice_ok(argp->rqstp);
if (readcount > 1 || max_reply > PAGE_SIZE - auth_slack)
argp->splice_ok = false;
But it is rather specific to NFSv4 COMPOUND processing.
There is this familiar-looking check in nfsd4_encode_splice_read() :
/*
* Splice read doesn't work if encoding has already wandered
* into the XDR buf's page array.
*/
if (unlikely(xdr->buf->page_len)) {
WARN_ON_ONCE(1);
return nfserr_serverfault;
}
Which probably works fine without the xdr_reserve_space_vec() call,
and might even be unnecessary.
I think nfsd4_encode_readv() needs to perform the check somehow.
The check for NFSv3 is always going to be simpler.
--
Chuck Lever
prev parent reply other threads:[~2025-09-24 18:56 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-22 14:11 [PATCH v3 0/3] NFSD direct I/O read Chuck Lever
2025-09-22 14:11 ` [PATCH v3 1/3] NFSD: filecache: add STATX_DIOALIGN and STATX_DIO_READ_ALIGN support Chuck Lever
2025-09-24 14:00 ` Chuck Lever
2025-09-22 14:11 ` [PATCH v3 2/3] NFSD: pass nfsd_file to nfsd_iter_read() Chuck Lever
2025-09-22 14:11 ` [PATCH v3 3/3] NFSD: Implement NFSD_IO_DIRECT for NFS READ Chuck Lever
2025-09-23 22:26 ` Mike Snitzer
2025-09-23 22:49 ` Chuck Lever
2025-09-23 23:31 ` Mike Snitzer
2025-09-23 23:48 ` NeilBrown
2025-09-23 23:52 ` Chuck Lever
2025-09-24 7:30 ` NeilBrown
2025-09-24 14:12 ` Mike Snitzer
2025-09-24 15:18 ` Mike Snitzer
2025-09-24 18:56 ` [RFC PATCH v3 4/3] NFSD: Implement NFSD_IO_DIRECT for NFS READ (v3 and older) [Was: "Re: [PATCH v3 3/3] NFSD: Implement NFSD_IO_DIRECT for NFS READ"] Mike Snitzer
2025-09-25 2:56 ` Jonathan Flynn
2025-09-25 13:13 ` Jonathan Flynn
2025-09-26 0:18 ` [PATCH v3 3/3] NFSD: Implement NFSD_IO_DIRECT for NFS READ NeilBrown
2025-09-26 1:30 ` Mike Snitzer
2025-09-24 18:56 ` Chuck Lever [this message]
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=5b82341d-bec2-4c99-826c-0fa8a7b49268@kernel.org \
--to=cel@kernel.org \
--cc=chuck.lever@oracle.com \
--cc=dai.ngo@oracle.com \
--cc=jlayton@kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=neil@brown.name \
--cc=okorniev@redhat.com \
--cc=snitzer@kernel.org \
--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;
as well as URLs for NNTP newsgroup(s).