From: Chuck Lever <cel@kernel.org>
To: Mike Snitzer <snitzer@kernel.org>
Cc: 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>,
linux-nfs@vger.kernel.org
Subject: Re: [PATCH v6 4/5] NFSD: Implement NFSD_IO_DIRECT for NFS WRITE
Date: Wed, 22 Oct 2025 17:09:35 -0400 [thread overview]
Message-ID: <ba83af9b-fd11-46d5-b63e-c6be0c989803@kernel.org> (raw)
In-Reply-To: <aPlFdJHa98jfc3m_@kernel.org>
On 10/22/25 4:58 PM, Mike Snitzer wrote:
> On Wed, Oct 22, 2025 at 03:22:07PM -0400, Chuck Lever wrote:
>> From: Mike Snitzer <snitzer@kernel.org>
>>
>> If NFSD_IO_DIRECT is used, split any misaligned WRITE into a start,
>> middle and end as needed. The large middle extent is DIO-aligned and
>> the start and/or end are misaligned. An O_SYNC buffered write (with
>> preference towards using DONTCACHE) is used for the misaligned extents
>> and O_DIRECT is used for the middle DIO-aligned extent.
>>
>> nfsd_issue_write_dio() promotes @stable_how to NFS_FILE_SYNC, which
>> allows the client to drop its dirty data and avoid needing an extra
>> COMMIT operation.
>>
>> Signed-off-by: Mike Snitzer <snitzer@kernel.org>
>> Reviewed-by: Jeff Layton <jlayton@kernel.org>
>> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
>> ---
>> fs/nfsd/debugfs.c | 1 +
>> fs/nfsd/trace.h | 1 +
>> fs/nfsd/vfs.c | 181 ++++++++++++++++++++++++++++++++++++++++++++++
>> 3 files changed, 183 insertions(+)
>>
>> diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
>> index 41cd2b53d803..29c29a5111f8 100644
>> --- a/fs/nfsd/vfs.c
>> +++ b/fs/nfsd/vfs.c
>> @@ -1254,6 +1254,105 @@ static int wait_for_concurrent_writes(struct file *file)
>> return err;
>> }
>>
>> +struct nfsd_write_dio {
>> + ssize_t start_len; /* Length for misaligned first extent */
>> + ssize_t middle_len; /* Length for DIO-aligned middle extent */
>> + ssize_t end_len; /* Length for misaligned last extent */
>> +};
>> +
>> +static bool
>> +nfsd_is_write_dio_possible(loff_t offset, unsigned long len,
>> + struct nfsd_file *nf,
>> + struct nfsd_write_dio *write_dio)
>> +{
>> + const u32 dio_blocksize = nf->nf_dio_offset_align;
>> + loff_t start_end, orig_end, middle_end;
>> +
>
> I see you removed this check:
>
> - if (unlikely(!nf->nf_dio_mem_align || !dio_blocksize))
> - return false;
>
> Curious why. Seems unsafe because they can be 0.
Hm. I might have removed the wrong check. Will fix that up for the next
round.
>
>> + if (unlikely(dio_blocksize > PAGE_SIZE || len < dio_blocksize))
>> + return false;
>> +
>> + start_end = round_up(offset, dio_blocksize);
>> + orig_end = offset + len;
>> + middle_end = round_down(orig_end, dio_blocksize);
>> +
>> + write_dio->start_len = start_end - offset;
>> + write_dio->middle_len = middle_end - start_end;
>> + write_dio->end_len = orig_end - middle_end;
>> +
>> + return true;
>> +}
>
> Otherwise, your other changes all seem fine.
>
> Thanks,
> Mike
--
Chuck Lever
next prev parent reply other threads:[~2025-10-22 21:09 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-22 19:22 [PATCH v6 0/5] NFSD: Implement NFSD_IO_DIRECT for NFS WRITE Chuck Lever
2025-10-22 19:22 ` [PATCH v6 1/5] NFSD: Make FILE_SYNC WRITEs comply with spec Chuck Lever
2025-10-22 19:22 ` [PATCH v6 2/5] NFSD: Enable return of an updated stable_how to NFS clients Chuck Lever
2025-10-22 19:22 ` [PATCH v6 3/5] NFSD: Refactor nfsd_vfs_write() Chuck Lever
2025-10-22 19:22 ` [PATCH v6 4/5] NFSD: Implement NFSD_IO_DIRECT for NFS WRITE Chuck Lever
2025-10-22 19:27 ` Chuck Lever
2025-10-22 21:09 ` Mike Snitzer
2025-10-22 20:58 ` Mike Snitzer
2025-10-22 21:09 ` Chuck Lever [this message]
2025-10-23 19:37 ` Chuck Lever
2025-10-23 21:23 ` Mike Snitzer
2025-10-24 14:24 ` Chuck Lever
2025-10-24 18:30 ` Mike Snitzer
2025-10-22 19:22 ` [PATCH v6 5/5] svcrdma: Mark Read chunks Chuck Lever
2025-10-22 21:25 ` Mike Snitzer
2025-10-23 13:00 ` Chuck Lever
2025-10-22 21:56 ` [PATCH v6 0/5] NFSD: Implement NFSD_IO_DIRECT for NFS WRITE 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=ba83af9b-fd11-46d5-b63e-c6be0c989803@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=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).