Skip to content

Commit

Permalink
block: optimize blk_bio_segment_split for single-page bvec
Browse files Browse the repository at this point in the history
Introduce a fast path for single-page bvec IO, then we can avoid
to call bvec_split_segs() unnecessarily.

Signed-off-by: Ming Lei <ming.lei@redhat.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
  • Loading branch information
Ming Lei authored and Jens Axboe committed Feb 27, 2019
1 parent 48d7727 commit bbcbbd5
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions block/blk-merge.c
Original file line number Diff line number Diff line change
Expand Up @@ -286,10 +286,16 @@ static struct bio *blk_bio_segment_split(struct request_queue *q,
bvprv = bv;
bvprvp = &bvprv;

if (bvec_split_segs(q, &bv, &nsegs, &seg_size,
&front_seg_size, &sectors))
if (bv.bv_offset + bv.bv_len <= PAGE_SIZE) {
nsegs++;
seg_size = bv.bv_len;
sectors += bv.bv_len >> 9;
if (nsegs == 1 && seg_size > front_seg_size)
front_seg_size = seg_size;
} else if (bvec_split_segs(q, &bv, &nsegs, &seg_size,
&front_seg_size, &sectors)) {
goto split;

}
}

do_split = false;
Expand Down

0 comments on commit bbcbbd5

Please sign in to comment.