]> git.ipfire.org Git - thirdparty/linux.git/commit
nfs/localio: avoid issuing misaligned IO using O_DIRECT
authorMike Snitzer <snitzer@kernel.org>
Fri, 19 Sep 2025 14:36:26 +0000 (10:36 -0400)
committerAnna Schumaker <anna.schumaker@oracle.com>
Tue, 30 Sep 2025 20:10:29 +0000 (16:10 -0400)
commit25ba2b84c38f624151a3ba36e56d41c39b9223ad
treecb30dcbb56b7a41bd95ce618bbd94292800e9ada
parentfd6d93c2b79ded0a447502ce5c8a9a549c697819
nfs/localio: avoid issuing misaligned IO using O_DIRECT

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>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Anna Schumaker <anna.schumaker@oracle.com>
fs/nfs/localio.c
fs/nfsd/localio.c
include/linux/nfslocalio.h