Skip to content

Commit a85b363

Browse files
Christoph Hellwigaxboe
authored andcommitted
block: move the call to get_max_io_size out of blk_bio_segment_split
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@lst.de> Reviewed-by: Damien Le Moal <damien.lemoal@opensource.wdc.com> Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> Link: https://lore.kernel.org/r/20220727162300.3089193-5-hch@lst.de Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 46754bd commit a85b363

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

block/blk-merge.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -250,11 +250,12 @@ static bool bvec_split_segs(const struct request_queue *q,
250250
* @q: [in] request queue pointer
251251
* @segs: [out] number of segments in the bio with the first half of the sectors
252252
* @bs: [in] bio set to allocate the clone from
253+
* @max_bytes: [in] maximum number of bytes per bio
253254
*
254255
* Clone @bio, update the bi_iter of the clone to represent the first sectors
255256
* of @bio and update @bio->bi_iter to represent the remaining sectors. The
256257
* following is guaranteed for the cloned bio:
257-
* - That it has at most get_max_io_size(@bio, @q) sectors.
258+
* - That it has at most @max_bytes worth of data
258259
* - That it has at most queue_max_segments(@q) segments.
259260
*
260261
* Except for discard requests the cloned bio will point at the bi_io_vec of
@@ -264,12 +265,11 @@ static bool bvec_split_segs(const struct request_queue *q,
264265
* split bio has finished.
265266
*/
266267
static struct bio *bio_split_rw(struct bio *bio, struct request_queue *q,
267-
unsigned *segs, struct bio_set *bs)
268+
unsigned *segs, struct bio_set *bs, unsigned max_bytes)
268269
{
269270
struct bio_vec bv, bvprv, *bvprvp = NULL;
270271
struct bvec_iter iter;
271272
unsigned nsegs = 0, bytes = 0;
272-
const unsigned max_bytes = get_max_io_size(bio, q) << 9;
273273
const unsigned max_segs = queue_max_segments(q);
274274

275275
bio_for_each_bvec(bv, bio, iter) {
@@ -343,7 +343,8 @@ struct bio *__bio_split_to_limits(struct bio *bio, struct request_queue *q,
343343
split = bio_split_write_zeroes(bio, q, nr_segs, bs);
344344
break;
345345
default:
346-
split = bio_split_rw(bio, q, nr_segs, bs);
346+
split = bio_split_rw(bio, q, nr_segs, bs,
347+
get_max_io_size(bio, q) << SECTOR_SHIFT);
347348
break;
348349
}
349350

0 commit comments

Comments
 (0)