Prepare for reusing blk_bio_segment_split for (file system controlled) splits of REQ_OP_ZONE_APPEND bios by letting the caller control the maximum size of the bio. Signed-off-by: Christoph Hellwig <hch@xxxxxx> --- block/blk-merge.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/block/blk-merge.c b/block/blk-merge.c index e657f1dc824cb..1676a835b16e7 100644 --- a/block/blk-merge.c +++ b/block/blk-merge.c @@ -252,11 +252,12 @@ static bool bvec_split_segs(const struct request_queue *q, * @bio: [in] bio to be split * @bs: [in] bio set to allocate the clone from * @segs: [out] number of segments in the bio with the first half of the sectors + * @max_bytes: [in] maximum number of bytes per bio * * Clone @bio, update the bi_iter of the clone to represent the first sectors * of @bio and update @bio->bi_iter to represent the remaining sectors. The * following is guaranteed for the cloned bio: - * - That it has at most get_max_io_size(@q, @bio) sectors. + * - That it has at most @max_bytes worth of data * - That it has at most queue_max_segments(@q) segments. * * Except for discard requests the cloned bio will point at the bi_io_vec of @@ -266,14 +267,12 @@ static bool bvec_split_segs(const struct request_queue *q, * split bio has finished. */ static struct bio *blk_bio_segment_split(struct request_queue *q, - struct bio *bio, - struct bio_set *bs, - unsigned *segs) + struct bio *bio, struct bio_set *bs, unsigned *segs, + unsigned max_bytes) { struct bio_vec bv, bvprv, *bvprvp = NULL; struct bvec_iter iter; unsigned nsegs = 0, bytes = 0; - const unsigned max_bytes = get_max_io_size(q, bio) << 9; const unsigned max_segs = queue_max_segments(q); bio_for_each_bvec(bv, bio, iter) { @@ -347,7 +346,8 @@ void __blk_queue_split(struct request_queue *q, struct bio **bio, split = blk_bio_write_zeroes_split(q, *bio, bs, nr_segs); break; default: - split = blk_bio_segment_split(q, *bio, bs, nr_segs); + split = blk_bio_segment_split(q, *bio, bs, nr_segs, + get_max_io_size(q, *bio) << SECTOR_SHIFT); break; } -- 2.30.2