summaryrefslogtreecommitdiffstats
path: root/block/blk-merge.c
diff options
context:
space:
mode:
authorKeith Busch <keith.busch@intel.com>2015-08-19 17:24:05 -0400
committerJens Axboe <axboe@fb.com>2015-08-19 17:26:02 -0400
commit03100aada96f0645bbcb89aea24c01f02d0ef1fa (patch)
treeba909d035a188206b101ae633f925e18d749f7cc /block/blk-merge.c
parentd2be537c3ba3568acd79cd178327b842e60d035e (diff)
block: Replace SG_GAPS with new queue limits mask
The SG_GAPS queue flag caused checks for bio vector alignment against PAGE_SIZE, but the device may have different constraints. This patch adds a queue limits so a driver with such constraints can set to allow requests that would have been unnecessarily split. The new gaps check takes the request_queue as a parameter to simplify the logic around invoking this function. This new limit makes the queue flag redundant, so removing it and all usage. Device-mappers will inherit the correct settings through blk_stack_limits(). Signed-off-by: Keith Busch <keith.busch@intel.com> Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'block/blk-merge.c')
-rw-r--r--block/blk-merge.c23
1 files changed, 7 insertions, 16 deletions
diff --git a/block/blk-merge.c b/block/blk-merge.c
index 0027def35f5a..0e0d9fd01c40 100644
--- a/block/blk-merge.c
+++ b/block/blk-merge.c
@@ -82,8 +82,7 @@ static struct bio *blk_bio_segment_split(struct request_queue *q,
82 * If the queue doesn't support SG gaps and adding this 82 * If the queue doesn't support SG gaps and adding this
83 * offset would create a gap, disallow it. 83 * offset would create a gap, disallow it.
84 */ 84 */
85 if (q->queue_flags & (1 << QUEUE_FLAG_SG_GAPS) && 85 if (prev && bvec_gap_to_prev(q, &bvprv, bv.bv_offset))
86 prev && bvec_gap_to_prev(&bvprv, bv.bv_offset))
87 goto split; 86 goto split;
88 87
89 if (prev && blk_queue_cluster(q)) { 88 if (prev && blk_queue_cluster(q)) {
@@ -484,12 +483,12 @@ static bool req_no_special_merge(struct request *req)
484 return !q->mq_ops && req->special; 483 return !q->mq_ops && req->special;
485} 484}
486 485
487static int req_gap_to_prev(struct request *req, struct request *next) 486static int req_gap_to_prev(struct request *req, struct bio *next)
488{ 487{
489 struct bio *prev = req->biotail; 488 struct bio *prev = req->biotail;
490 489
491 return bvec_gap_to_prev(&prev->bi_io_vec[prev->bi_vcnt - 1], 490 return bvec_gap_to_prev(req->q, &prev->bi_io_vec[prev->bi_vcnt - 1],
492 next->bio->bi_io_vec[0].bv_offset); 491 next->bi_io_vec[1].bv_offset);
493} 492}
494 493
495static int ll_merge_requests_fn(struct request_queue *q, struct request *req, 494static int ll_merge_requests_fn(struct request_queue *q, struct request *req,
@@ -506,8 +505,7 @@ static int ll_merge_requests_fn(struct request_queue *q, struct request *req,
506 if (req_no_special_merge(req) || req_no_special_merge(next)) 505 if (req_no_special_merge(req) || req_no_special_merge(next))
507 return 0; 506 return 0;
508 507
509 if (test_bit(QUEUE_FLAG_SG_GAPS, &q->queue_flags) && 508 if (req_gap_to_prev(req, next->bio))
510 req_gap_to_prev(req, next))
511 return 0; 509 return 0;
512 510
513 /* 511 /*
@@ -692,8 +690,6 @@ int blk_attempt_req_merge(struct request_queue *q, struct request *rq,
692 690
693bool blk_rq_merge_ok(struct request *rq, struct bio *bio) 691bool blk_rq_merge_ok(struct request *rq, struct bio *bio)
694{ 692{
695 struct request_queue *q = rq->q;
696
697 if (!rq_mergeable(rq) || !bio_mergeable(bio)) 693 if (!rq_mergeable(rq) || !bio_mergeable(bio))
698 return false; 694 return false;
699 695
@@ -718,13 +714,8 @@ bool blk_rq_merge_ok(struct request *rq, struct bio *bio)
718 return false; 714 return false;
719 715
720 /* Only check gaps if the bio carries data */ 716 /* Only check gaps if the bio carries data */
721 if (q->queue_flags & (1 << QUEUE_FLAG_SG_GAPS) && bio_has_data(bio)) { 717 if (bio_has_data(bio) && req_gap_to_prev(rq, bio))
722 struct bio_vec *bprev; 718 return false;
723
724 bprev = &rq->biotail->bi_io_vec[rq->biotail->bi_vcnt - 1];
725 if (bvec_gap_to_prev(bprev, bio->bi_io_vec[0].bv_offset))
726 return false;
727 }
728 719
729 return true; 720 return true;
730} 721}