Linux NFS development
 help / color / mirror / Atom feed
From: Mike Snitzer <snitzer@kernel.org>
To: Anna Schumaker <anna.schumaker@oracle.com>,
	Chuck Lever <chuck.lever@oracle.com>,
	Jeff Layton <jlayton@kernel.org>
Cc: Anna Schumaker <anna@kernel.org>,
	Trond Myklebust <trond.myklebust@hammerspace.com>,
	linux-nfs@vger.kernel.org
Subject: Re: [PATCH v10 2/7] nfs/localio: avoid issuing misaligned IO using O_DIRECT
Date: Thu, 18 Sep 2025 13:31:48 -0400	[thread overview]
Message-ID: <aMxCBIEFuBC0RiS7@kernel.org> (raw)
In-Reply-To: <404a4c49-9e16-46d1-8901-f7a8a6a9701b@oracle.com>

On Thu, Sep 18, 2025 at 01:15:10PM -0400, Anna Schumaker wrote:
> Hi Mike,
> 
> On 9/17/25 2:18 PM, Mike Snitzer wrote:
> > Add nfsd_file_dio_alignment and use it to avoid issuing misaligned IO
> > using O_DIRECT. Any misaligned DIO falls back to using buffered IO.
> > 
> > Because misaligned DIO is now handled safely, remove the nfs modparam
> > 'localio_O_DIRECT_semantics' that was added to require users opt-in to
> > the requirement that all O_DIRECT be properly DIO-aligned.
> > 
> > Also, introduce nfs_iov_iter_aligned_bvec() which is a variant of
> > iov_iter_aligned_bvec() that also verifies the offset associated with
> > an iov_iter is DIO-aligned.  NOTE: in a parallel effort,
> > iov_iter_aligned_bvec() is being removed along with
> > iov_iter_is_aligned().
> > 
> > Lastly, add pr_info_ratelimited if underlying filesystem returns
> > -EINVAL because it was made to try O_DIRECT for IO that is not
> > DIO-aligned (shouldn't happen, so its best to be louder if it does).
> > 
> > Fixes: 3feec68563d ("nfs/localio: add direct IO enablement with sync and async IO support")
> > Signed-off-by: Mike Snitzer <snitzer@kernel.org>
> > ---
> >  fs/nfs/localio.c           | 69 ++++++++++++++++++++++++++++++++------
> >  fs/nfsd/localio.c          | 11 ++++++
> >  include/linux/nfslocalio.h |  2 ++
> >  3 files changed, 72 insertions(+), 10 deletions(-)
> > 
> > diff --git a/fs/nfs/localio.c b/fs/nfs/localio.c
> > index 42ea50d42c995..380407c41822c 100644
> > --- a/fs/nfs/localio.c
> > +++ b/fs/nfs/localio.c

<snip>

> > @@ -406,6 +441,13 @@ nfs_local_read_done(struct nfs_local_kiocb *iocb, long status)
> >  	struct nfs_pgio_header *hdr = iocb->hdr;
> >  	struct file *filp = iocb->kiocb.ki_filp;
> >  
> > +	if (iocb->kiocb.ki_flags & IOCB_DIRECT) {
> > +		if (status == -EINVAL) {
> > +			/* Underlying FS will return -EINVAL if misaligned DIO is attempted. */
> > +			pr_info_ratelimited("nfs: Unexpected direct I/O read alignment failure\n");
> > +		}
> > +	}
> > +
> >  	nfs_local_pgio_done(hdr, status);
> >  
> >  	/*
> > @@ -598,6 +640,13 @@ nfs_local_write_done(struct nfs_local_kiocb *iocb, long status)
> >  
> >  	dprintk("%s: wrote %ld bytes.\n", __func__, status > 0 ? status : 0);
> >  
> > +	if (iocb->kiocb.ki_flags & IOCB_DIRECT) {
> > +		if (status == -EINVAL) {
> > +			/* Underlying FS will return -EINVAL if misaligned DIO is attempted. */
> > +			pr_info_ratelimited("nfs: Unexpected direct I/O write alignment failure\n");
> > +		}
> > +	}
> > +
> >  	/* Handle short writes as if they are ENOSPC */
> >  	if (status > 0 && status < hdr->args.count) {
> >  		hdr->mds_offset += status;

I'm just noticing these 2 hunks above. I revised them to remove 1
level of nesting but it seems that wasn't folded in early (in this
patch 2) but instead was left until patch 5 to cleanup.

You can leave patch 2 and 5 like they are, just mentioning this
because fixing up patch 2 to reflect how patch 5 left things for these
two hunks would reduce patch 5's changes/churn.

I can also carry that change through and post a v11 -- will wait to do
so until you've been able to get through the rest of the series in
case there are other things that need fixing.

> > diff --git a/fs/nfsd/localio.c b/fs/nfsd/localio.c
> > index 269fa9391dc46..be710d809a3ba 100644
> > --- a/fs/nfsd/localio.c
> > +++ b/fs/nfsd/localio.c
> 
> I'll need an acked-by from Chuck or Jeff for the NFSD portions of this patch.
>
> Thanks,
> Anna

Absolutely, I should've cc'd them (I've done so now).

Thanks,
Mike

  reply	other threads:[~2025-09-18 17:31 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-17 18:18 [PATCH v10 0/7] NFS Direct: align misaligned DIO for LOCALIO Mike Snitzer
2025-09-17 18:18 ` [PATCH v10 1/7] nfs/localio: make trace_nfs_local_open_fh more useful Mike Snitzer
2025-09-17 18:18 ` [PATCH v10 2/7] nfs/localio: avoid issuing misaligned IO using O_DIRECT Mike Snitzer
2025-09-18 17:15   ` Anna Schumaker
2025-09-18 17:31     ` Mike Snitzer [this message]
2025-09-18 18:55     ` Chuck Lever
2025-09-18 19:17       ` Mike Snitzer
2025-09-17 18:18 ` [PATCH v10 3/7] nfs/localio: refactor iocb and iov_iter_bvec initialization Mike Snitzer
2025-09-17 18:18 ` [PATCH v10 4/7] nfs/localio: refactor iocb initialization Mike Snitzer
2025-09-17 18:18 ` [PATCH v10 5/7] nfs/localio: add proper O_DIRECT support for READ and WRITE Mike Snitzer
2025-09-17 18:18 ` [PATCH v10 6/7] nfs/localio: add tracepoints for misaligned DIO READ and WRITE support Mike Snitzer
2025-09-18 17:33   ` Anna Schumaker
2025-09-18 17:46     ` Mike Snitzer
2025-09-18 17:55       ` Anna Schumaker
2025-09-18 19:21         ` Mike Snitzer
2025-09-18 19:55           ` Anna Schumaker
2025-09-18 20:18             ` Mike Snitzer
2025-09-18 21:03               ` Mike Snitzer
2025-09-18 21:06                 ` Anna Schumaker
2025-09-18 21:07                 ` Anna Schumaker
2025-09-18 21:41                   ` Mike Snitzer
2025-09-17 18:18 ` [PATCH v10 7/7] NFS: add basic STATX_DIOALIGN and STATX_DIO_READ_ALIGN support 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=aMxCBIEFuBC0RiS7@kernel.org \
    --to=snitzer@kernel.org \
    --cc=anna.schumaker@oracle.com \
    --cc=anna@kernel.org \
    --cc=chuck.lever@oracle.com \
    --cc=jlayton@kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=trond.myklebust@hammerspace.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