block: only honor SG gap prevention for merges that contain data
authorJens Axboe <axboe@fb.com>
Fri, 29 May 2015 19:10:23 +0000 (13:10 -0600)
committerJens Axboe <axboe@fb.com>
Fri, 29 May 2015 19:10:23 +0000 (13:10 -0600)
We can safely merge anything that wont generate an SG list entry,
so if the bio is data-less (discard), don't look at potential
SG gaps.

Signed-off-by: Jens Axboe <axboe@fb.com>
block/blk-merge.c

index fd3fee81c23ce2f1cdc73d2bf4e76188c90358cb..30a0d9f890170b7540546557b950713b8e372780 100644 (file)
@@ -589,7 +589,8 @@ bool blk_rq_merge_ok(struct request *rq, struct bio *bio)
            !blk_write_same_mergeable(rq->bio, bio))
                return false;
 
-       if (q->queue_flags & (1 << QUEUE_FLAG_SG_GAPS)) {
+       /* Only check gaps if the bio carries data */
+       if (q->queue_flags & (1 << QUEUE_FLAG_SG_GAPS) && bio_has_data(bio)) {
                struct bio_vec *bprev;
 
                bprev = &rq->biotail->bi_io_vec[rq->biotail->bi_vcnt - 1];