block: check bio_mergeable() early before merging
authorMing Lei <ming.lei@canonical.com>
Tue, 20 Oct 2015 15:13:55 +0000 (23:13 +0800)
committerJens Axboe <axboe@fb.com>
Wed, 21 Oct 2015 21:00:54 +0000 (15:00 -0600)
After bio splitting is introduced, one bio can be splitted
and it is marked as NOMERGE because it is too fat to be merged,
so check bio_mergeable() earlier to avoid to try to merge it
unnecessarily.

Signed-off-by: Ming Lei <ming.lei@canonical.com>
Reviewed-by: Jeff Moyer <jmoyer@redhat.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
block/elevator.c

index 84d63943f2de2f386ff35e6a395f68ada173b5b2..c3555c9c672f94c1f13c3cd3c75c037e7c8110a7 100644 (file)
@@ -420,7 +420,7 @@ int elv_merge(struct request_queue *q, struct request **req, struct bio *bio)
         *      noxmerges: Only simple one-hit cache try
         *      merges:    All merge tries attempted
         */
-       if (blk_queue_nomerges(q))
+       if (blk_queue_nomerges(q) || !bio_mergeable(bio))
                return ELEVATOR_NO_MERGE;
 
        /*