On Thu, Sep 18, 2025 at 04:27:14PM -0400, Mike Snitzer wrote: > On Thu, Sep 18, 2025 at 09:16:42AM -0700, Keith Busch wrote: > > From: Keith Busch <[email protected]> > > > > Most storage devices can handle DMA for data that is not aligned to the > > sector block size. The block and filesystem layers have introduced > > updates to allow that kind of memory alignment flexibility when > > possible. > > I'd love to understand what changes in filesystems you're referring > to. Because I know for certain that DIO with memory that isn't > 'dma_alignment' aligned fails with certainty ontop of XFS.
I only mentioned the "sector block size" alignment, not the hardware dma alignment. The dma alignment remains the minimum address alignment you have to use. But xfs has been able to handle dword aligned addresses for a while now, assuming your block_device can handle dword aligned DMA. But the old requirement for a buffer to be aligned to a 4k address offset for a 4k block device isn't necessary anymore. > Pretty certain it balks at DIO that isn't logical_block_size aligned > ondisk too. We might be talking about different things. The total length of a vector must be a multiple of the logical block size, yes. But I'm talking about the address offset. Right now dm-crypt can't handle a request if the address offset is not aligned to the logical block size. But that's a purely software created limitation, there's no hard reason that needs to be the case. > > it sends a single scatterlist element for the input ot the encrypt and > > decrypt algorithms. This forces applications that have unaligned data to > > copy through a bounce buffer, increasing CPU and memory utilization. > > Even this notion that an application is somehow able to (unwittingly) > lean on "unaligned data to copy through a bounce buffer" -- has me > asking: where does Keith get these wonderful toys? I'm just trying to write data to disk from buffers filled by NICs subscribed to io_uring zero-copy receive capabilities. I guess they need fancy features to do that, but it's not that uncommon, is it? Anyway, the data that needs to be persisted often have offsets that are still DMA friendly, but unlikely to be perfectly page aligned.
