summaryrefslogtreecommitdiffstats
path: root/block/blk-merge.c
diff options
context:
space:
mode:
authorJens Axboe <axboe@fb.com>2014-06-25 00:22:24 +0200
committerJens Axboe <axboe@fb.com>2014-06-25 00:22:24 +0200
commit66cb45aa41315d1d9972cada354fbdf7870d7714 (patch)
tree5ca5ef3c31f24a7a11989d8a6a163eed9aaf9528 /block/blk-merge.c
parentbio: remove unused macro bip_vec_idx() (diff)
downloadlinux-66cb45aa41315d1d9972cada354fbdf7870d7714.tar.xz
linux-66cb45aa41315d1d9972cada354fbdf7870d7714.zip
block: add support for limiting gaps in SG lists
Another restriction inherited for NVMe - those devices don't support SG lists that have "gaps" in them. Gaps refers to cases where the previous SG entry doesn't end on a page boundary. For NVMe, all SG entries must start at offset 0 (except the first) and end on a page boundary (except the last). Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'block/blk-merge.c')
-rw-r--r--block/blk-merge.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/block/blk-merge.c b/block/blk-merge.c
index b3bf0df0f4c2..54535831f1e1 100644
--- a/block/blk-merge.c
+++ b/block/blk-merge.c
@@ -568,6 +568,8 @@ int blk_attempt_req_merge(struct request_queue *q, struct request *rq,
bool blk_rq_merge_ok(struct request *rq, struct bio *bio)
{
+ struct request_queue *q = rq->q;
+
if (!rq_mergeable(rq) || !bio_mergeable(bio))
return false;
@@ -591,6 +593,14 @@ 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)) {
+ struct bio_vec *bprev;
+
+ bprev = &rq->biotail->bi_io_vec[bio->bi_vcnt - 1];
+ if (bvec_gap_to_prev(bprev, bio->bi_io_vec[0].bv_offset))
+ return false;
+ }
+
return true;
}