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-13T05:46:01Z

On Thu, Jun 12, 2025 at 12:22:42PM -0400, Jeff Layton wrote:
> If you're against the idea, I won't waste my time.
>
> It would require some fairly hefty rejiggering of the receive code. The
> v4 part would be pretty nightmarish to work out too since you'd have to
> decode the compound as you receive to tell where the next op starts.
>
> The potential for corruption with unaligned writes is also pretty
> nasty.

Maybe I'm missing an improvement to the receive buffer handling in modern
network hardware, but AFAIK this still would only help you to align the
sunrpc data buffer to page boundaries, but avoid the data copy from the
hardware receive buffer to the sunrpc data buffer as you still don't have
hardware header splitting.

And I don't even know what this is supposed to buy the nfs server.
Direct I/O writes need to have the proper file offset alignment, but as
far as Linux is concerned we don't require any memory alignment. Most
storage hardware has requirements for the memory alignment that we pass
on, but typically that's just a dword (4-byte) alignment, which matches
the alignment sunrpc wants for most XDR data structures anyway. So what
additional alignment is actually needed for support direct I/O writes
assuming that is the goal? (I might also simply misunderstand the
problem).