diff options
Diffstat (limited to 'block/blk-merge.c')
-rw-r--r-- | block/blk-merge.c | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/block/blk-merge.c b/block/blk-merge.c index 6c583f9c5b65..b3bf0df0f4c2 100644 --- a/block/blk-merge.c +++ b/block/blk-merge.c | |||
@@ -13,7 +13,7 @@ static unsigned int __blk_recalc_rq_segments(struct request_queue *q, | |||
13 | struct bio *bio) | 13 | struct bio *bio) |
14 | { | 14 | { |
15 | struct bio_vec bv, bvprv = { NULL }; | 15 | struct bio_vec bv, bvprv = { NULL }; |
16 | int cluster, high, highprv = 1; | 16 | int cluster, high, highprv = 1, no_sg_merge; |
17 | unsigned int seg_size, nr_phys_segs; | 17 | unsigned int seg_size, nr_phys_segs; |
18 | struct bio *fbio, *bbio; | 18 | struct bio *fbio, *bbio; |
19 | struct bvec_iter iter; | 19 | struct bvec_iter iter; |
@@ -35,12 +35,21 @@ static unsigned int __blk_recalc_rq_segments(struct request_queue *q, | |||
35 | cluster = blk_queue_cluster(q); | 35 | cluster = blk_queue_cluster(q); |
36 | seg_size = 0; | 36 | seg_size = 0; |
37 | nr_phys_segs = 0; | 37 | nr_phys_segs = 0; |
38 | no_sg_merge = test_bit(QUEUE_FLAG_NO_SG_MERGE, &q->queue_flags); | ||
39 | high = 0; | ||
38 | for_each_bio(bio) { | 40 | for_each_bio(bio) { |
39 | bio_for_each_segment(bv, bio, iter) { | 41 | bio_for_each_segment(bv, bio, iter) { |
40 | /* | 42 | /* |
43 | * If SG merging is disabled, each bio vector is | ||
44 | * a segment | ||
45 | */ | ||
46 | if (no_sg_merge) | ||
47 | goto new_segment; | ||
48 | |||
49 | /* | ||
41 | * the trick here is making sure that a high page is | 50 | * the trick here is making sure that a high page is |
42 | * never considered part of another segment, since that | 51 | * never considered part of another segment, since |
43 | * might change with the bounce page. | 52 | * that might change with the bounce page. |
44 | */ | 53 | */ |
45 | high = page_to_pfn(bv.bv_page) > queue_bounce_pfn(q); | 54 | high = page_to_pfn(bv.bv_page) > queue_bounce_pfn(q); |
46 | if (!high && !highprv && cluster) { | 55 | if (!high && !highprv && cluster) { |
@@ -84,11 +93,16 @@ void blk_recalc_rq_segments(struct request *rq) | |||
84 | 93 | ||
85 | void blk_recount_segments(struct request_queue *q, struct bio *bio) | 94 | void blk_recount_segments(struct request_queue *q, struct bio *bio) |
86 | { | 95 | { |
87 | struct bio *nxt = bio->bi_next; | 96 | if (test_bit(QUEUE_FLAG_NO_SG_MERGE, &q->queue_flags)) |
97 | bio->bi_phys_segments = bio->bi_vcnt; | ||
98 | else { | ||
99 | struct bio *nxt = bio->bi_next; | ||
100 | |||
101 | bio->bi_next = NULL; | ||
102 | bio->bi_phys_segments = __blk_recalc_rq_segments(q, bio); | ||
103 | bio->bi_next = nxt; | ||
104 | } | ||
88 | 105 | ||
89 | bio->bi_next = NULL; | ||
90 | bio->bi_phys_segments = __blk_recalc_rq_segments(q, bio); | ||
91 | bio->bi_next = nxt; | ||
92 | bio->bi_flags |= (1 << BIO_SEG_VALID); | 106 | bio->bi_flags |= (1 << BIO_SEG_VALID); |
93 | } | 107 | } |
94 | EXPORT_SYMBOL(blk_recount_segments); | 108 | EXPORT_SYMBOL(blk_recount_segments); |