Skip to content

Commit bbcbbd5

Browse files
Ming Leiaxboe
authored andcommitted
block: optimize blk_bio_segment_split for single-page bvec
Introduce a fast path for single-page bvec IO, then we can avoid to call bvec_split_segs() unnecessarily. Signed-off-by: Ming Lei <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent 48d7727 commit bbcbbd5

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

block/blk-merge.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -286,10 +286,16 @@ static struct bio *blk_bio_segment_split(struct request_queue *q,
286286
bvprv = bv;
287287
bvprvp = &bvprv;
288288

289-
if (bvec_split_segs(q, &bv, &nsegs, &seg_size,
290-
&front_seg_size, &sectors))
289+
if (bv.bv_offset + bv.bv_len <= PAGE_SIZE) {
290+
nsegs++;
291+
seg_size = bv.bv_len;
292+
sectors += bv.bv_len >> 9;
293+
if (nsegs == 1 && seg_size > front_seg_size)
294+
front_seg_size = seg_size;
295+
} else if (bvec_split_segs(q, &bv, &nsegs, &seg_size,
296+
&front_seg_size, &sectors)) {
291297
goto split;
292-
298+
}
293299
}
294300

295301
do_split = false;

0 commit comments

Comments
 (0)