Linux NFS development
 help / color / mirror / Atom feed
From: Chuck Lever <cel@kernel.org>
To: NeilBrown <neil@brown.name>
Cc: 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>,
	Mike Snitzer <snitzer@kernel.org>
Subject: Re: [PATCH v1 3/3] NFSD: Implement NFSD_IO_DIRECT for NFS READ
Date: Wed, 10 Sep 2025 10:23:54 -0400	[thread overview]
Message-ID: <7d340996-9671-46fa-8ad1-8b656b6fe2e2@kernel.org> (raw)
In-Reply-To: <175746915802.2850467.11582824964664652427@noble.neil.brown.name>

On 9/9/25 9:52 PM, NeilBrown wrote:
>>>> +	v = 0;
>>>> +	total = dio_end - dio_start;
>>>> +	while (total) {
>>>> +		len = min_t(size_t, total, PAGE_SIZE);
>>>> +		bvec_set_page(&rqstp->rq_bvec[v], *(rqstp->rq_next_page++),
>>>> +			      len, 0);
>>>> +		total -= len;
>>>> +		++v;
>>>> +	}
>>>> +	WARN_ON_ONCE(v > rqstp->rq_maxpages);
>>> I would rather we had an early test rather than a late warn-on.
>>> e.g.
>>>   if (total > (rqstp->rq_maxpages >> PAGE_SHIFT))
>>>      return -EINVAL /* or whatever */;
>>>
>>> Otherwise it seems to be making unstated assumptions about how big the
>>> alignment requirements could be.
>> This is the same warn-on test that nfsd_iter_read does for buffered and
>> dontcache reads. It's done late because the final value of v is computed
>> here, not known before the loop.
> True, but in this case "total" could be larger than "*count" which was
> size-checked in e.g.  nfsd4_encode_read.  So it could now be larger than
> the available space.

Expanding the byte range is constrained to the alignment parameters,
meaning the most the range can increase is by a single page (assuming
the needed alignment is always less than or equal to a page size, or
that we stipulate larger alignments are not yet supported).

Both rq_bvec and rq_pages have that extra page already.


>> I think we might be able to turn this into a short read, for all I/O
>> modes?
> Yes, that could be a clean way to handle the unlikely case that the
> reads doesn't fit any more.

It's probably best to not have the WARN_ON at all. Either convert the
failure to a short read, or prove formally that the condition cannot
happen and simply remove the WARN_ON. I have never seen it fire.

That should be done to nfsd_iter_read() /before/ this series. Then 3/3
can "copy" and use the improved loop logic.


-- 
Chuck Lever

  reply	other threads:[~2025-09-10 14:23 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-09 19:05 [PATCH v1 0/3] NFSD direct I/O read Chuck Lever
2025-09-09 19:05 ` [PATCH v1 1/3] NFSD: filecache: add STATX_DIOALIGN and STATX_DIO_READ_ALIGN support Chuck Lever
2025-09-09 23:07   ` NeilBrown
2025-09-09 19:05 ` [PATCH v1 2/3] NFSD: pass nfsd_file to nfsd_iter_read() Chuck Lever
2025-09-09 23:20   ` NeilBrown
2025-09-09 19:05 ` [PATCH v1 3/3] NFSD: Implement NFSD_IO_DIRECT for NFS READ Chuck Lever
2025-09-09 23:16   ` Mike Snitzer
2025-09-09 23:37   ` NeilBrown
2025-09-09 23:39     ` Chuck Lever
2025-09-09 23:48       ` Chuck Lever
2025-09-10  1:54         ` NeilBrown
2025-09-10  1:52       ` NeilBrown
2025-09-10 14:23         ` Chuck Lever [this message]
2025-09-09 23:56     ` Mike Snitzer
2025-09-10 11:37   ` Jeff Layton
2025-09-09 23:33 ` [PATCH 0/2] NFSD: continuation of NFSD DIRECT Mike Snitzer
2025-09-09 23:33   ` [PATCH 1/2] sunrpc: add an extra reserve page to svc_serv_maxpages() Mike Snitzer
2025-09-10 14:29     ` Chuck Lever
2025-09-09 23:33   ` [PATCH 2/2] NFSD: Implement NFSD_IO_DIRECT for NFS WRITE Mike Snitzer
2025-10-08 18:59     ` [PATCH v2] " Mike Snitzer
2025-10-09 15:04       ` Jeff Layton
2025-10-09 17:46       ` Chuck Lever
2025-10-13 15:41         ` Mike Snitzer

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=7d340996-9671-46fa-8ad1-8b656b6fe2e2@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