Re: [PATCH 05/17] iomap: respect maximum I/O size in iomap_dio_bio_iter_one

From
Darrick J. Wong <djwong@kernel.org>
Date
2026-08-31 17:55:42
Also in
linux-fsdevel, linux-xfs
Reply to
Christoph Hellwig, 2026-08-31
On Mon, Aug 31, 2026 at 09:39:53AM +0300, Christoph Hellwig wrote:
Respect the maximum I/O size set for PI-enabled I/O in
iomap_dio_bio_iter_one, otherwise bio_integrity_alloc_buf could
under-allocate the integrity buffer when the initial kmalloc fails.

Currently this should not be triggered as file systems that limit the
size for PI always use bounce buffering, but this will change soon.

Signed-off-by: Christoph Hellwig <hch@lst.de>
This makes sense, as the !DIO_BOUNCE path will soon get used for the
"don't bounce, just try it and see if it fails" code path.

Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>

--D
quoted hunk ↗ jump to hunk
---
 fs/iomap/direct-io.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/fs/iomap/direct-io.c b/fs/iomap/direct-io.c
index bc726d47b7dc..91f5b67718a5 100644
--- a/fs/iomap/direct-io.c
+++ b/fs/iomap/direct-io.c
@@ -336,6 +336,7 @@ static ssize_t iomap_dio_bio_iter_one(struct iomap_iter *iter,
 		struct iomap_dio *dio, loff_t pos, unsigned int alignment,
 		blk_opf_t op)
 {
+	unsigned int maxsize = iomap_max_bio_size(&iter->iomap);
 	unsigned int nr_vecs;
 	struct bio *bio;
 	ssize_t ret;
@@ -353,14 +354,12 @@ static ssize_t iomap_dio_bio_iter_one(struct iomap_iter *iter,
 	bio->bi_private = dio;
 	bio->bi_end_io = iomap_dio_bio_end_io;
 
-
 	if (dio->flags & IOMAP_DIO_BOUNCE)
-		ret = bio_iov_iter_bounce(bio, dio->submit.iter,
-				iomap_max_bio_size(&iter->iomap), alignment);
+		ret = bio_iov_iter_bounce(bio, dio->submit.iter, maxsize,
+				alignment);
 	else
-		ret = bio_iov_iter_get_pages(bio, dio->submit.iter,
-				BIO_MAX_SIZE, bdev_dma_alignment(bio->bi_bdev),
-				alignment - 1);
+		ret = bio_iov_iter_get_pages(bio, dio->submit.iter, maxsize,
+				bdev_dma_alignment(bio->bi_bdev), alignment - 1);
 	if (unlikely(ret))
 		goto out_put_bio;
 	ret = bio->bi_iter.bi_size;
-- 
2.53.0
Thread (33 messages) 33 messages, 3 authors, last reply 2026-09-07
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help