diff options
author | Christoph Hellwig <hch@lst.de> | 2018-09-24 03:43:52 -0400 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2018-09-24 14:33:57 -0400 |
commit | 3dccdae54fe836a22cee9dc6df9fd1708ae075ce (patch) | |
tree | 95d8808538de6f977086e2603d75694d7c1848bc /block | |
parent | 0e253391a970300fe4ae69d0c1d1ab494eb07508 (diff) |
block: merge BIOVEC_SEG_BOUNDARY into biovec_phys_mergeable
These two checks should always be performed together, so merge them into
a single helper.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block')
-rw-r--r-- | block/bio.c | 4 | ||||
-rw-r--r-- | block/blk-integrity.c | 12 | ||||
-rw-r--r-- | block/blk-merge.c | 29 | ||||
-rw-r--r-- | block/blk.h | 12 |
4 files changed, 17 insertions, 40 deletions
diff --git a/block/bio.c b/block/bio.c index c254e5aa331f..e9f92b50724d 100644 --- a/block/bio.c +++ b/block/bio.c | |||
@@ -731,9 +731,7 @@ int bio_add_pc_page(struct request_queue *q, struct bio *bio, struct page | |||
731 | } | 731 | } |
732 | 732 | ||
733 | /* If we may be able to merge these biovecs, force a recount */ | 733 | /* If we may be able to merge these biovecs, force a recount */ |
734 | if (bio->bi_vcnt > 1 && | 734 | if (bio->bi_vcnt > 1 && biovec_phys_mergeable(q, bvec - 1, bvec)) |
735 | biovec_phys_mergeable(bvec - 1, bvec) && | ||
736 | BIOVEC_SEG_BOUNDARY(q, bvec - 1, bvec)) | ||
737 | bio_clear_flag(bio, BIO_SEG_VALID); | 735 | bio_clear_flag(bio, BIO_SEG_VALID); |
738 | 736 | ||
739 | done: | 737 | done: |
diff --git a/block/blk-integrity.c b/block/blk-integrity.c index 0f7267916509..d1ab089e0919 100644 --- a/block/blk-integrity.c +++ b/block/blk-integrity.c | |||
@@ -49,12 +49,8 @@ int blk_rq_count_integrity_sg(struct request_queue *q, struct bio *bio) | |||
49 | bio_for_each_integrity_vec(iv, bio, iter) { | 49 | bio_for_each_integrity_vec(iv, bio, iter) { |
50 | 50 | ||
51 | if (prev) { | 51 | if (prev) { |
52 | if (!biovec_phys_mergeable(&ivprv, &iv)) | 52 | if (!biovec_phys_mergeable(q, &ivprv, &iv)) |
53 | goto new_segment; | 53 | goto new_segment; |
54 | |||
55 | if (!BIOVEC_SEG_BOUNDARY(q, &ivprv, &iv)) | ||
56 | goto new_segment; | ||
57 | |||
58 | if (seg_size + iv.bv_len > queue_max_segment_size(q)) | 54 | if (seg_size + iv.bv_len > queue_max_segment_size(q)) |
59 | goto new_segment; | 55 | goto new_segment; |
60 | 56 | ||
@@ -95,12 +91,8 @@ int blk_rq_map_integrity_sg(struct request_queue *q, struct bio *bio, | |||
95 | bio_for_each_integrity_vec(iv, bio, iter) { | 91 | bio_for_each_integrity_vec(iv, bio, iter) { |
96 | 92 | ||
97 | if (prev) { | 93 | if (prev) { |
98 | if (!biovec_phys_mergeable(&ivprv, &iv)) | 94 | if (!biovec_phys_mergeable(q, &ivprv, &iv)) |
99 | goto new_segment; | 95 | goto new_segment; |
100 | |||
101 | if (!BIOVEC_SEG_BOUNDARY(q, &ivprv, &iv)) | ||
102 | goto new_segment; | ||
103 | |||
104 | if (sg->length + iv.bv_len > queue_max_segment_size(q)) | 96 | if (sg->length + iv.bv_len > queue_max_segment_size(q)) |
105 | goto new_segment; | 97 | goto new_segment; |
106 | 98 | ||
diff --git a/block/blk-merge.c b/block/blk-merge.c index 5e63e8259f92..42a46744c11b 100644 --- a/block/blk-merge.c +++ b/block/blk-merge.c | |||
@@ -21,9 +21,7 @@ static inline bool bios_segs_mergeable(struct request_queue *q, | |||
21 | struct bio *prev, struct bio_vec *prev_last_bv, | 21 | struct bio *prev, struct bio_vec *prev_last_bv, |
22 | struct bio_vec *next_first_bv) | 22 | struct bio_vec *next_first_bv) |
23 | { | 23 | { |
24 | if (!biovec_phys_mergeable(prev_last_bv, next_first_bv)) | 24 | if (!biovec_phys_mergeable(q, prev_last_bv, next_first_bv)) |
25 | return false; | ||
26 | if (!BIOVEC_SEG_BOUNDARY(q, prev_last_bv, next_first_bv)) | ||
27 | return false; | 25 | return false; |
28 | if (prev->bi_seg_back_size + next_first_bv->bv_len > | 26 | if (prev->bi_seg_back_size + next_first_bv->bv_len > |
29 | queue_max_segment_size(q)) | 27 | queue_max_segment_size(q)) |
@@ -199,9 +197,7 @@ static struct bio *blk_bio_segment_split(struct request_queue *q, | |||
199 | if (bvprvp && blk_queue_cluster(q)) { | 197 | if (bvprvp && blk_queue_cluster(q)) { |
200 | if (seg_size + bv.bv_len > queue_max_segment_size(q)) | 198 | if (seg_size + bv.bv_len > queue_max_segment_size(q)) |
201 | goto new_segment; | 199 | goto new_segment; |
202 | if (!biovec_phys_mergeable(bvprvp, &bv)) | 200 | if (!biovec_phys_mergeable(q, bvprvp, &bv)) |
203 | goto new_segment; | ||
204 | if (!BIOVEC_SEG_BOUNDARY(q, bvprvp, &bv)) | ||
205 | goto new_segment; | 201 | goto new_segment; |
206 | 202 | ||
207 | seg_size += bv.bv_len; | 203 | seg_size += bv.bv_len; |
@@ -332,9 +328,7 @@ static unsigned int __blk_recalc_rq_segments(struct request_queue *q, | |||
332 | if (seg_size + bv.bv_len | 328 | if (seg_size + bv.bv_len |
333 | > queue_max_segment_size(q)) | 329 | > queue_max_segment_size(q)) |
334 | goto new_segment; | 330 | goto new_segment; |
335 | if (!biovec_phys_mergeable(&bvprv, &bv)) | 331 | if (!biovec_phys_mergeable(q, &bvprv, &bv)) |
336 | goto new_segment; | ||
337 | if (!BIOVEC_SEG_BOUNDARY(q, &bvprv, &bv)) | ||
338 | goto new_segment; | 332 | goto new_segment; |
339 | 333 | ||
340 | seg_size += bv.bv_len; | 334 | seg_size += bv.bv_len; |
@@ -414,17 +408,7 @@ static int blk_phys_contig_segment(struct request_queue *q, struct bio *bio, | |||
414 | bio_get_last_bvec(bio, &end_bv); | 408 | bio_get_last_bvec(bio, &end_bv); |
415 | bio_get_first_bvec(nxt, &nxt_bv); | 409 | bio_get_first_bvec(nxt, &nxt_bv); |
416 | 410 | ||
417 | if (!biovec_phys_mergeable(&end_bv, &nxt_bv)) | 411 | return biovec_phys_mergeable(q, &end_bv, &nxt_bv); |
418 | return 0; | ||
419 | |||
420 | /* | ||
421 | * bio and nxt are contiguous in memory; check if the queue allows | ||
422 | * these two to be merged into one | ||
423 | */ | ||
424 | if (BIOVEC_SEG_BOUNDARY(q, &end_bv, &nxt_bv)) | ||
425 | return 1; | ||
426 | |||
427 | return 0; | ||
428 | } | 412 | } |
429 | 413 | ||
430 | static inline void | 414 | static inline void |
@@ -438,10 +422,7 @@ __blk_segment_map_sg(struct request_queue *q, struct bio_vec *bvec, | |||
438 | if (*sg && *cluster) { | 422 | if (*sg && *cluster) { |
439 | if ((*sg)->length + nbytes > queue_max_segment_size(q)) | 423 | if ((*sg)->length + nbytes > queue_max_segment_size(q)) |
440 | goto new_segment; | 424 | goto new_segment; |
441 | 425 | if (!biovec_phys_mergeable(q, bvprv, bvec)) | |
442 | if (!biovec_phys_mergeable(bvprv, bvec)) | ||
443 | goto new_segment; | ||
444 | if (!BIOVEC_SEG_BOUNDARY(q, bvprv, bvec)) | ||
445 | goto new_segment; | 426 | goto new_segment; |
446 | 427 | ||
447 | (*sg)->length += nbytes; | 428 | (*sg)->length += nbytes; |
diff --git a/block/blk.h b/block/blk.h index aed99cbc1bca..8f7229b6f63e 100644 --- a/block/blk.h +++ b/block/blk.h | |||
@@ -153,13 +153,19 @@ static inline void blk_queue_enter_live(struct request_queue *q) | |||
153 | #define ARCH_BIOVEC_PHYS_MERGEABLE(vec1, vec2) true | 153 | #define ARCH_BIOVEC_PHYS_MERGEABLE(vec1, vec2) true |
154 | #endif | 154 | #endif |
155 | 155 | ||
156 | static inline bool biovec_phys_mergeable(const struct bio_vec *vec1, | 156 | static inline bool biovec_phys_mergeable(struct request_queue *q, |
157 | const struct bio_vec *vec2) | 157 | struct bio_vec *vec1, struct bio_vec *vec2) |
158 | { | 158 | { |
159 | if (bvec_to_phys(vec1) + vec1->bv_len != bvec_to_phys(vec2)) | 159 | unsigned long mask = queue_segment_boundary(q); |
160 | phys_addr_t addr1 = bvec_to_phys(vec1); | ||
161 | phys_addr_t addr2 = bvec_to_phys(vec2); | ||
162 | |||
163 | if (addr1 + vec1->bv_len != addr2) | ||
160 | return false; | 164 | return false; |
161 | if (!ARCH_BIOVEC_PHYS_MERGEABLE(vec1, vec2)) | 165 | if (!ARCH_BIOVEC_PHYS_MERGEABLE(vec1, vec2)) |
162 | return false; | 166 | return false; |
167 | if ((addr1 | mask) != ((addr2 + vec2->bv_len - 1) | mask)) | ||
168 | return false; | ||
163 | return true; | 169 | return true; |
164 | } | 170 | } |
165 | 171 | ||