Re: need SUNRPC TCP to receive into aligned pages [was: Re: [PATCH 1/6] NFSD: add the ability to enable use of RWF_DONTCACHE for all IO]

Christoph Hellwig
2025-06-16T12:29:32Z

On Fri, Jun 13, 2025 at 05:23:48AM -0400, Mike Snitzer wrote:
> Which in practice has proven a hard requirement for O_DIRECT in my
> testing

What fails if you don't page align the memory?

> But if you looking at patch 5 in this series:
> https://lore.kernel.org/linux-nfs/20250610205737.63343-6-snitzer@kernel.org/
>
> I added fs/nfsd/vfs.c:is_dio_aligned(), which is basically a tweaked
> ditto of fs/btrfs/direct-io.c:check_direct_IO():

No idea why btrfs still has this, but it's not a general requirement
from the block layer or other file system. You just need to be
aligned to the dma alignment in the queue limits, which for most NVMe,
SCSI or ATA devices reports a dword alignment. Some of the more
obscure drivers might require more alignment, or just report it due to
copy and paste.

> What I found is that unless SUNRPC TPC stored the WRITE payload in a
> page-aligned boundary then iov_iter_alignment() would fail.

iov_iter_alignment would fail, or yout check based on it? The latter
will fail, but it doesn't check anything that matters :)