summaryrefslogtreecommitdiffstats
path: root/block
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
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')
-rw-r--r--block/bio.c3
-rw-r--r--block/blk-merge.c23
-rw-r--r--block/blk-settings.c14
3 files changed, 22 insertions, 18 deletions
diff --git a/block/bio.c b/block/bio.c
index 425d6d4a2f7a..b1f198f9a317 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -742,8 +742,7 @@ int bio_add_pc_page(struct request_queue *q, struct bio *bio, struct page
742 * If the queue doesn't support SG gaps and adding this 742 * If the queue doesn't support SG gaps and adding this
743 * offset would create a gap, disallow it. 743 * offset would create a gap, disallow it.
744 */ 744 */
745 if (q->queue_flags & (1 << QUEUE_FLAG_SG_GAPS) && 745 if (bvec_gap_to_prev(q, prev, offset))
746 bvec_gap_to_prev(prev, offset))
747 return 0; 746 return 0;
748 } 747 }
749 748
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}
diff --git a/block/blk-settings.c b/block/blk-settings.c
index d27b4e272356..f96c72116931 100644
--- a/block/blk-settings.c
+++ b/block/blk-settings.c
@@ -89,6 +89,7 @@ void blk_set_default_limits(struct queue_limits *lim)
89 lim->max_segments = BLK_MAX_SEGMENTS; 89 lim->max_segments = BLK_MAX_SEGMENTS;
90 lim->max_integrity_segments = 0; 90 lim->max_integrity_segments = 0;
91 lim->seg_boundary_mask = BLK_SEG_BOUNDARY_MASK; 91 lim->seg_boundary_mask = BLK_SEG_BOUNDARY_MASK;
92 lim->virt_boundary_mask = 0;
92 lim->max_segment_size = BLK_MAX_SEGMENT_SIZE; 93 lim->max_segment_size = BLK_MAX_SEGMENT_SIZE;
93 lim->max_sectors = lim->max_hw_sectors = BLK_SAFE_MAX_SECTORS; 94 lim->max_sectors = lim->max_hw_sectors = BLK_SAFE_MAX_SECTORS;
94 lim->chunk_sectors = 0; 95 lim->chunk_sectors = 0;
@@ -532,6 +533,8 @@ int blk_stack_limits(struct queue_limits *t, struct queue_limits *b,
532 533
533 t->seg_boundary_mask = min_not_zero(t->seg_boundary_mask, 534 t->seg_boundary_mask = min_not_zero(t->seg_boundary_mask,
534 b->seg_boundary_mask); 535 b->seg_boundary_mask);
536 t->virt_boundary_mask = min_not_zero(t->virt_boundary_mask,
537 b->virt_boundary_mask);
535 538
536 t->max_segments = min_not_zero(t->max_segments, b->max_segments); 539 t->max_segments = min_not_zero(t->max_segments, b->max_segments);
537 t->max_integrity_segments = min_not_zero(t->max_integrity_segments, 540 t->max_integrity_segments = min_not_zero(t->max_integrity_segments,
@@ -772,6 +775,17 @@ void blk_queue_segment_boundary(struct request_queue *q, unsigned long mask)
772EXPORT_SYMBOL(blk_queue_segment_boundary); 775EXPORT_SYMBOL(blk_queue_segment_boundary);
773 776
774/** 777/**
778 * blk_queue_virt_boundary - set boundary rules for bio merging
779 * @q: the request queue for the device
780 * @mask: the memory boundary mask
781 **/
782void blk_queue_virt_boundary(struct request_queue *q, unsigned long mask)
783{
784 q->limits.virt_boundary_mask = mask;
785}
786EXPORT_SYMBOL(blk_queue_virt_boundary);
787
788/**
775 * blk_queue_dma_alignment - set dma length and memory alignment 789 * blk_queue_dma_alignment - set dma length and memory alignment
776 * @q: the request queue for the device 790 * @q: the request queue for the device
777 * @mask: alignment mask 791 * @mask: alignment mask