]> git.ipfire.org Git - thirdparty/linux.git/commit
iomap: add IOMAP_DIO_FSBLOCK_ALIGNED flag
authorQu Wenruo <wqu@suse.com>
Fri, 31 Oct 2025 13:10:26 +0000 (14:10 +0100)
committerChristian Brauner <brauner@kernel.org>
Wed, 5 Nov 2025 12:09:27 +0000 (13:09 +0100)
commit001397f5ef4908ea46a63059439e8c3bf3552d9f
treeb6d68a2fa34f2974859ab27c7ebbc88cefadbee5
parent560507cbc151cf5c02d8831781e4912e64587298
iomap: add IOMAP_DIO_FSBLOCK_ALIGNED flag

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>
Reviewed-by: Pankaj Raghav <p.raghav@samsung.com>
[hch: also align pos/len, incorporate the trace flags from Darrick]
Signed-off-by: Christoph Hellwig <hch@lst.de>
Link: https://patch.msgid.link/20251031131045.1613229-2-hch@lst.de
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Christian Brauner <brauner@kernel.org>
fs/iomap/direct-io.c
fs/iomap/trace.h
include/linux/iomap.h