block: optimize blk_bio_segment_split for single-page bvec
authorMing Lei <ming.lei@redhat.com>
Wed, 27 Feb 2019 12:40:12 +0000 (20:40 +0800)
committerJens Axboe <axboe@kernel.dk>
Wed, 27 Feb 2019 13:18:55 +0000 (06:18 -0700)
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>
block/blk-merge.c

index c1ad8ab..9402a7c 100644 (file)
@@ -286,10 +286,16 @@ new_segment:
                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;