Re: [PATCHv2 4/6] loop: set dma_alignment from the backing file for direct I/O

Christoph Hellwig <[email protected]>
Newsgroups dev.linux.lists.dm-devel,org.kernel.vger.linux-block,org.kernel.vger.linux-fsdevel
Message-ID <[email protected]>
On Mon, Jun 22, 2026 at 10:42:39AM -0700, Keith Busch wrote:
>  	/*
> -	 * Use the minimal dio alignment of the file system if provided.
> +	 * Use the dio alignment of the file system if provided.  dio_offset_align
> +	 * is the minimum dio size and offset; dio_mem_align is the buffer memory
> +	 * alignment, kept as a mask to become the loop device's dma_alignment in
> +	 * direct I/O mode where the buffer is handed to the backing file unchanged.

A bunch of overly long lines here.

> +	 * In direct I/O the user pages are handed to the backing file as-is, so
> +	 * the backing's DMA alignment requirement applies to them.  Advertise it
> +	 * so misaligned I/O is rejected at this device's entry instead of being
> +	 * dispatched to the backend.  Buffered I/O copies through the page cache
> +	 * and imposes no such requirement.
> +	 */

More line spillover here.

> +	if (lo->lo_flags & LO_FLAGS_DIRECT_IO)
> +		lim->dma_alignment = lo->lo_dio_mem_align;
> +	else
> +		lim->dma_alignment = SECTOR_SIZE - 1;

Despite the comment above this does enforce a SECTOR_SIZE dma
alignment for buffered I/O.  Shouldn't this be our lowest supported
value (or dword alignment to match real devices)?

> +	lim = queue_limits_start_update(lo->lo_queue);
> +	if (lo->lo_flags & LO_FLAGS_DIRECT_IO)
> +		lim.dma_alignment = lo->lo_dio_mem_align;
> +	else
> +		lim.dma_alignment = SECTOR_SIZE - 1;

Should this and the above copy of this assignment be factored into a
helper?
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.