Re: [PATCH v2] iomap: add IOMAP_DIO_FSBLOCK_ALIGNED flag

Pankaj Raghav (Samsung)
2025-10-16T12:10:17Z

On Mon, Oct 13, 2025 at 07:35:16PM +1030, Qu Wenruo wrote:
> Btrfs requires all of its bios to be fs block aligned, normally it's
> totally fine but with the incoming block size larger than page size
> (bs > ps) support, the requirement is no longer met for direct IOs.
>
> Because iomap_dio_bio_iter() calls bio_iov_iter_get_pages(), only
> requiring alignment to be bdev_logical_block_size().
>
> In the real world that value is either 512 or 4K, on 4K page sized
> systems it means bio_iov_iter_get_pages() can break the bio at any page
> boundary, breaking btrfs' requirement for bs > ps cases.
>
> To address this problem, introduce a new public iomap dio flag,
> IOMAP_DIO_FSBLOCK_ALIGNED.
>
> When calling __iomap_dio_rw() with that new flag, iomap_dio::flags will
> inherit that new flag, and iomap_dio_bio_iter() will take fs block size
> into the calculation of the alignment, and pass the alignment to
> bio_iov_iter_get_pages(), respecting the fs block size requirement.
>
> The initial user of this flag will be btrfs, which needs to calculate the
> checksum for direct read and thus requires the biovec to be fs block
> aligned for the incoming bs > ps support.
>
> Signed-off-by: Qu Wenruo <wqu@suse.com>
> ---

Looks good.
Reviewed-by: Pankaj Raghav <p.raghav@samsung.com>
--
Pankaj