cleanup for the recent bio_iov_iter_get_pages changes
Subsystems (2)
Hi all,
while looking over the bio splitting issue reported by Qu, I noticed that some of the recent changes to bio_iov_iter_get_pages lead to more indirections than really needed, especially with the bcachefs abuse now removed in 6.18-rc. This small series cleans this up an prepares for the file system block size splitting needed by btrfs bs > PAGE_SIZE support.
Diffstat:
block/bio.c | 5 ++--- block/blk-map.c | 6 +++++- block/fops.c | 13 ++++++++++--- fs/iomap/direct-io.c | 3 ++- include/linux/bio.h | 7 +------ include/linux/blkdev.h | 7 ------- 6 files changed, 20 insertions(+), 21 deletions(-)
PATCH 1/4 block: remove bio_iov_iter_get_pages
Switch the only caller to bio_iov_iter_get_pages, and explain why it does not have any alignment requirements.
--- block/blk-map.c | 6 +++++- include/linux/bio.h | 5 ----- 2 files changed, 5 insertions(+), 6 deletions(-)
block/blk-map.c +5 -1
@@ -283,7 +283,11 @@ static int bio_map_user_iov(struct request *rq, struct iov_iter *iter, bio =blk_rq_map_bio_alloc (rq, nr_vecs, gfp_mask);if (!bio)return -ENOMEM ; - ret =bio_iov_iter_get_pages (bio, iter); +/* +* No alignment requirements on our part to support arbitrary +* passthrough commands. +*/ + ret =bio_iov_iter_get_pages_aligned (bio, iter,0 );if (ret) goto out_put; ret =blk_rq_append_bio (rq, bio);
include/linux/bio.h +0 -5
@@ -449,11 +449,6 @@ int bdev_rw_virt(struct block_device *bdev, sector_t sector, void *data,int bio_iov_iter_get_pages_aligned (struct bio *bio,struct iov_iter *iter,unsigned len_align_mask); -static inline int bio_iov_iter_get_pages (struct bio *bio,struct iov_iter *iter) -{ -return bio_iov_iter_get_pages_aligned (bio, iter,0 ); -} -void bio_iov_bvec_set (struct bio *bio,const struct iov_iter *iter);void __bio_release_pages (struct bio *bio,bool mark_dirty);extern void bio_set_pages_dirty (struct bio *bio);
Signature · 1 line
2.47.3
PATCH 2/4 block: rename bio_iov_iter_get_pages_aligned to bio_iov_iter_get_pages
In reply to Christoph HellwigNow that the bio_iov_iter_get_pages is free again, use it instead of the more complicated now. Also drop the unused export.
--- block/bio.c | 5 ++--- block/blk-map.c | 2 +- include/linux/bio.h | 2 +- include/linux/blkdev.h | 2 +- 4 files changed, 5 insertions(+), 6 deletions(-)
block/bio.c +2 -3
@@ -1316,7 +1316,7 @@ static int bio_iov_iter_align_down(struct bio *bio, struct iov_iter *iter, }/** -* bio_iov_iter_get_pages_aligned - add user or kernel pages to a bio +* bio_iov_iter_get_pages - add user or kernel pages to a bio * @bio: bio to add pages to * @iter: iov iterator describing the region to be added * @len_align_mask: the mask to align the total size to, 0 for any length
@@ -1336,7 +1336,7 @@ static int bio_iov_iter_align_down(struct bio *bio, struct iov_iter *iter,* MM encounters an error pinning the requested pages, it stops. Error * is returned only if 0 pages could be pinned. */ -int bio_iov_iter_get_pages_aligned (struct bio *bio,struct iov_iter *iter, +int bio_iov_iter_get_pages (struct bio *bio,struct iov_iter *iter,unsigned len_align_mask) {int ret =0 ;
@@ -1360,7 +1360,6 @@ int bio_iov_iter_get_pages_aligned(struct bio *bio, struct iov_iter *iter,return bio_iov_iter_align_down (bio, iter, len_align_mask);return ret; } -EXPORT_SYMBOL_GPL (bio_iov_iter_get_pages_aligned);static void submit_bio_wait_endio (struct bio *bio) {
block/blk-map.c +1 -1
@@ -287,7 +287,7 @@ static int bio_map_user_iov(struct request *rq, struct iov_iter *iter,* No alignment requirements on our part to support arbitrary * passthrough commands. */ - ret =bio_iov_iter_get_pages_aligned (bio, iter,0 ); + ret =bio_iov_iter_get_pages (bio, iter,0 );if (ret) goto out_put; ret =blk_rq_append_bio (rq, bio);
include/linux/bio.h +1 -1
@@ -446,7 +446,7 @@ int submit_bio_wait(struct bio *bio);int bdev_rw_virt (struct block_device *bdev,sector_t sector,void *data,size_t len,enum req_op op); -int bio_iov_iter_get_pages_aligned (struct bio *bio,struct iov_iter *iter, +int bio_iov_iter_get_pages (struct bio *bio,struct iov_iter *iter,unsigned len_align_mask);void bio_iov_bvec_set (struct bio *bio,const struct iov_iter *iter);
include/linux/blkdev.h +1 -1
@@ -1876,7 +1876,7 @@ static inline int bio_split_rw_at(struct bio *bio,static inline int bio_iov_iter_get_bdev_pages (struct bio *bio,struct iov_iter *iter,struct block_device *bdev) { -return bio_iov_iter_get_pages_aligned (bio, iter, +return bio_iov_iter_get_pages (bio, iter,bdev_logical_block_size (bdev) -1 ); }
Signature · 1 line
2.47.3
PATCH 3/4 iomap: open code bio_iov_iter_get_bdev_pages
In reply to Christoph HellwigPrepare for passing different alignments, and to retired bio_iov_iter_get_bdev_pages as a global helper.
--- fs/iomap/direct-io.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/iomap/direct-io.c +2 -1
@@ -433,7 +433,8 @@ static int iomap_dio_bio_iter(struct iomap_iter *iter, struct iomap_dio *dio) bio->bi_private = dio; bio->bi_end_io = iomap_dio_bio_end_io; - ret =bio_iov_iter_get_bdev_pages (bio, dio->submit.iter, iomap->bdev); + ret =bio_iov_iter_get_pages (bio, dio->submit.iter, +bdev_logical_block_size (iomap->bdev) -1 );if (unlikely (ret)) {/* * We have to stop part way through an IO. We must fall
Signature · 1 line
2.47.3
PATCH 4/4 block: move bio_iov_iter_get_bdev_pages to block/fops.c
In reply to Christoph HellwigKeep bio_iov_iter_get_bdev_pages local with the callers, as blindly looking at the bdev logical block size is often not the best idea unless on a block device.
--- block/fops.c | 13 ++++++++++--- include/linux/blkdev.h | 7 ------- 2 files changed, 10 insertions(+), 10 deletions(-)
block/fops.c +10 -3
@@ -43,6 +43,13 @@ static bool blkdev_dio_invalid(struct block_device *bdev, struct kiocb *iocb, (bdev_logical_block_size (bdev) -1 ); } +static inline int blkdev_iov_iter_get_pages (struct bio *bio, +struct iov_iter *iter,struct block_device *bdev) +{ +return bio_iov_iter_get_pages (bio, iter, +bdev_logical_block_size (bdev) -1 ); +} +#define DIO_INLINE_BIO_VECS 4 static ssize_t __blkdev_direct_IO_simple(struct kiocb *iocb,
@@ -78,7 +85,7 @@ static ssize_t __blkdev_direct_IO_simple(struct kiocb *iocb,if (iocb->ki_flags &IOCB_ATOMIC ) bio.bi_opf |=REQ_ATOMIC ; - ret =bio_iov_iter_get_bdev_pages (&bio, iter, bdev); + ret =blkdev_iov_iter_get_pages (&bio, iter, bdev);if (unlikely (ret)) goto out; ret = bio.bi_iter.bi_size;
@@ -212,7 +219,7 @@ static ssize_t __blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter, bio->bi_end_io = blkdev_bio_end_io; bio->bi_ioprio = iocb->ki_ioprio; - ret =bio_iov_iter_get_bdev_pages (bio, iter, bdev); + ret =blkdev_iov_iter_get_pages (bio, iter, bdev);if (unlikely (ret)) { bio->bi_status =BLK_STS_IOERR ;bio_endio (bio);
@@ -348,7 +355,7 @@ static ssize_t __blkdev_direct_IO_async(struct kiocb *iocb,*/ bio_iov_bvec_set (bio, iter); }else { - ret =bio_iov_iter_get_bdev_pages (bio, iter, bdev); + ret =blkdev_iov_iter_get_pages (bio, iter, bdev);if (unlikely (ret)) goto out_bio_put; }
include/linux/blkdev.h +0 -7
@@ -1873,13 +1873,6 @@ static inline int bio_split_rw_at(struct bio *bio, return bio_split_io_at(bio, lim, segs, max_bytes, lim->dma_alignment); } -static inline int bio_iov_iter_get_bdev_pages (struct bio *bio, -struct iov_iter *iter,struct block_device *bdev) -{ -return bio_iov_iter_get_pages (bio, iter, -bdev_logical_block_size (bdev) -1 ); -} -#define DEFINE_IO_COMP_BATCH (name) struct io_comp_batch name = { }#endif /* _LINUX_BLKDEV_H */
Signature · 1 line
2.47.3
Re: [PATCH 4/4] block: move bio_iov_iter_get_bdev_pages to block/fops.c
Dear patch submitter,
Blktests CI has tested the following submission:
Status: FAILURE Name: [4/4] block: move bio_iov_iter_get_bdev_pages to block/fops.c Patchwork: https://patchwork.kernel.org/project/linux-block/list/?series=1008963&state=* Run record: https://github.com/linux-blktests/linux-block/actions/runs/18307874888
No failure
Re: [PATCH 4/4] block: move bio_iov_iter_get_bdev_pages to block/fops.c
Quoted 2 lines · On Tue, Oct 07, 2025 at 04:57:40AM -0700, [email protected] wrote:
Blktests CI has tested the following submission:
Status: FAILURE
...
Quoted 1 line
No failure
o_O
Re: [PATCH 4/4] block: move bio_iov_iter_get_bdev_pages to block/fops.c
Quoted 9 lines · Keith Busch
Quoted 2 lines · On Tue, Oct 07, 2025 at 04:57:40AM -0700, [email protected] wrote:
Blktests CI has tested the following submission:
Status: FAILURE...
Quoted 1 line
No failure
o_O
Sorry about the noise and the confusing report. I enabled the blktests CI automated testing system, but it didn't go well. I have stopped the system, and will work on the fix.
Qu Wenruo
Reviewed-byQuoted 8 lines · Christoph Hellwig
Hi all,
while looking over the bio splitting issue reported by Qu, I noticed that some of the recent changes to
bio_iov_iter_get_pageslead to more indirections than really needed, especially with the bcachefs abuse now removed in 6.18-rc. This small series cleans this up an prepares for the file system block size splitting needed by btrfs bs >PAGE_SIZEsupport.
Looks good to me, and makes my later changes much easier.
Thanks,
Qu
Quoted 9 lines
Diffstat:
block/bio.c | 5 ++--- block/blk-map.c | 6 +++++- block/fops.c | 13 ++++++++++--- fs/iomap/direct-io.c | 3 ++- include/linux/bio.h | 7 +------ include/linux/blkdev.h | 7 ------- 6 files changed, 20 insertions(+), 21 deletions(-)
Keith Busch
Reviewed-byQuoted 6 lines · Christoph Hellwig
while looking over the bio splitting issue reported by Qu, I noticed that some of the recent changes to
bio_iov_iter_get_pageslead to more indirections than really needed, especially with the bcachefs abuse now removed in 6.18-rc. This small series cleans this up an prepares for the file system block size splitting needed by btrfs bs >PAGE_SIZEsupport.
Looks good to me.
Johannes Thumshirn
Reviewed-byLooks good,
Martin K. Petersen
Reviewed-byChristoph,
Quoted 6 lines
while looking over the bio splitting issue reported by Qu, I noticed that some of the recent changes to
bio_iov_iter_get_pageslead to more indirections than really needed, especially with the bcachefs abuse now removed in 6.18-rc. This small series cleans this up an prepares for the file system block size splitting needed by btrfs bs >PAGE_SIZEsupport.
Looks fine.
Signature · 1 line
Martin K. Petersen
Quoted 8 lines · Christoph Hellwig
while looking over the bio splitting issue reported by Qu, I noticed that some of the recent changes to
bio_iov_iter_get_pageslead to more indirections than really needed, especially with the bcachefs abuse now removed in 6.18-rc. This small series cleans this up an prepares for the file system block size splitting needed by btrfs bs >PAGE_SIZEsupport.[...]
Applied, thanks!
[1/4] block: remove bio_iov_iter_get_pages
commit: 1ed06c83506ecaaf1836ddeb7c65772ff86d8d53
[2/4] block: rename bio_iov_iter_get_pages_aligned to bio_iov_iter_get_pages
commit: 82dd5d763c9b718e2d655b9565e0a06a91bb83dc
[3/4] iomap: open code bio_iov_iter_get_bdev_pages
commit: cb6d51a4115781fd9de6108932e866a332e38406
[4/4] block: move bio_iov_iter_get_bdev_pages to block/fops.c
commit: 506aa235f6e0baa00bf792df82a5e9f618b7a5d8Best regards,
Signature · 1 line
Jens Axboe