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.
Unified · Split
| @@ -589,7 +589,8 @@ bool blk_rq_merge_ok(struct request *rq, struct bio *bio) · 588 unmodified lines | ||
| 589 | 589 | !blk_write_same_mergeable(rq->bio, bio)) |
| 590 | 590 | return false; |
| 591 | 591 | |
| 592 | − if (q->queue_flags & (1 << QUEUE_FLAG_SG_GAPS)) { | |
| 592 | + /* Only check gaps if the bio carries data */ | |
| 593 | + if (q->queue_flags & (1 << QUEUE_FLAG_SG_GAPS) && bio_has_data(bio)) { | |
| 593 | 594 | struct bio_vec *bprev; |
| 594 | 595 | |
| 595 | 596 | bprev = &rq->biotail->bi_io_vec[rq->biotail->bi_vcnt - 1]; |