Skip to content

Commit 6a9f5f2

Browse files
Christoph Hellwigaxboe
authored andcommitted
block: simplify BIOVEC_PHYS_MERGEABLE
Turn the macro into an inline, move it to blk.h and simplify the arch hooks a bit. Also rename the function to biovec_phys_mergeable as there is no need to shout. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 27ca1d4 commit 6a9f5f2

8 files changed

Lines changed: 28 additions & 30 deletions

File tree

‎arch/arm/include/asm/io.h‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -469,9 +469,8 @@ extern void pci_iounmap(struct pci_dev *dev, void __iomem *addr);
469469
struct bio_vec;
470470
extern bool xen_biovec_phys_mergeable(const struct bio_vec *vec1,
471471
const struct bio_vec *vec2);
472-
#define BIOVEC_PHYS_MERGEABLE(vec1, vec2) \
473-
(__BIOVEC_PHYS_MERGEABLE(vec1, vec2) && \
474-
(!xen_domain() || xen_biovec_phys_mergeable(vec1, vec2)))
472+
#define ARCH_BIOVEC_PHYS_MERGEABLE(vec1, vec2) \
473+
(!xen_domain() || xen_biovec_phys_mergeable(vec1, vec2))
475474

476475
#ifdef CONFIG_MMU
477476
#define ARCH_HAS_VALID_PHYS_ADDR_RANGE

‎arch/arm64/include/asm/io.h‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,9 +208,8 @@ extern int devmem_is_allowed(unsigned long pfn);
208208
struct bio_vec;
209209
extern bool xen_biovec_phys_mergeable(const struct bio_vec *vec1,
210210
const struct bio_vec *vec2);
211-
#define BIOVEC_PHYS_MERGEABLE(vec1, vec2) \
212-
(__BIOVEC_PHYS_MERGEABLE(vec1, vec2) && \
213-
(!xen_domain() || xen_biovec_phys_mergeable(vec1, vec2)))
211+
#define ARCH_BIOVEC_PHYS_MERGEABLE(vec1, vec2) \
212+
(!xen_domain() || xen_biovec_phys_mergeable(vec1, vec2))
214213

215214
#endif /* __KERNEL__ */
216215
#endif /* __ASM_IO_H */

‎arch/x86/include/asm/io.h‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -376,9 +376,8 @@ struct bio_vec;
376376
extern bool xen_biovec_phys_mergeable(const struct bio_vec *vec1,
377377
const struct bio_vec *vec2);
378378

379-
#define BIOVEC_PHYS_MERGEABLE(vec1, vec2) \
380-
(__BIOVEC_PHYS_MERGEABLE(vec1, vec2) && \
381-
(!xen_domain() || xen_biovec_phys_mergeable(vec1, vec2)))
379+
#define ARCH_BIOVEC_PHYS_MERGEABLE(vec1, vec2) \
380+
(!xen_domain() || xen_biovec_phys_mergeable(vec1, vec2))
382381
#endif /* CONFIG_XEN */
383382

384383
#define IO_SPACE_LIMIT 0xffff

‎block/bio.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -731,7 +731,7 @@ int bio_add_pc_page(struct request_queue *q, struct bio *bio, struct page
731731
}
732732

733733
/* If we may be able to merge these biovecs, force a recount */
734-
if (bio->bi_vcnt > 1 && (BIOVEC_PHYS_MERGEABLE(bvec-1, bvec)))
734+
if (bio->bi_vcnt > 1 && biovec_phys_mergeable(bvec-1, bvec))
735735
bio_clear_flag(bio, BIO_SEG_VALID);
736736

737737
done:

‎block/blk-integrity.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ int blk_rq_count_integrity_sg(struct request_queue *q, struct bio *bio)
4949
bio_for_each_integrity_vec(iv, bio, iter) {
5050

5151
if (prev) {
52-
if (!BIOVEC_PHYS_MERGEABLE(&ivprv, &iv))
52+
if (!biovec_phys_mergeable(&ivprv, &iv))
5353
goto new_segment;
5454

5555
if (!BIOVEC_SEG_BOUNDARY(q, &ivprv, &iv))
@@ -95,7 +95,7 @@ int blk_rq_map_integrity_sg(struct request_queue *q, struct bio *bio,
9595
bio_for_each_integrity_vec(iv, bio, iter) {
9696

9797
if (prev) {
98-
if (!BIOVEC_PHYS_MERGEABLE(&ivprv, &iv))
98+
if (!biovec_phys_mergeable(&ivprv, &iv))
9999
goto new_segment;
100100

101101
if (!BIOVEC_SEG_BOUNDARY(q, &ivprv, &iv))

‎block/blk-merge.c‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ static inline bool bios_segs_mergeable(struct request_queue *q,
2121
struct bio *prev, struct bio_vec *prev_last_bv,
2222
struct bio_vec *next_first_bv)
2323
{
24-
if (!BIOVEC_PHYS_MERGEABLE(prev_last_bv, next_first_bv))
24+
if (!biovec_phys_mergeable(prev_last_bv, next_first_bv))
2525
return false;
2626
if (!BIOVEC_SEG_BOUNDARY(q, prev_last_bv, next_first_bv))
2727
return false;
@@ -199,7 +199,7 @@ static struct bio *blk_bio_segment_split(struct request_queue *q,
199199
if (bvprvp && blk_queue_cluster(q)) {
200200
if (seg_size + bv.bv_len > queue_max_segment_size(q))
201201
goto new_segment;
202-
if (!BIOVEC_PHYS_MERGEABLE(bvprvp, &bv))
202+
if (!biovec_phys_mergeable(bvprvp, &bv))
203203
goto new_segment;
204204
if (!BIOVEC_SEG_BOUNDARY(q, bvprvp, &bv))
205205
goto new_segment;
@@ -332,7 +332,7 @@ static unsigned int __blk_recalc_rq_segments(struct request_queue *q,
332332
if (seg_size + bv.bv_len
333333
> queue_max_segment_size(q))
334334
goto new_segment;
335-
if (!BIOVEC_PHYS_MERGEABLE(&bvprv, &bv))
335+
if (!biovec_phys_mergeable(&bvprv, &bv))
336336
goto new_segment;
337337
if (!BIOVEC_SEG_BOUNDARY(q, &bvprv, &bv))
338338
goto new_segment;
@@ -414,7 +414,7 @@ static int blk_phys_contig_segment(struct request_queue *q, struct bio *bio,
414414
bio_get_last_bvec(bio, &end_bv);
415415
bio_get_first_bvec(nxt, &nxt_bv);
416416

417-
if (!BIOVEC_PHYS_MERGEABLE(&end_bv, &nxt_bv))
417+
if (!biovec_phys_mergeable(&end_bv, &nxt_bv))
418418
return 0;
419419

420420
/*
@@ -439,7 +439,7 @@ __blk_segment_map_sg(struct request_queue *q, struct bio_vec *bvec,
439439
if ((*sg)->length + nbytes > queue_max_segment_size(q))
440440
goto new_segment;
441441

442-
if (!BIOVEC_PHYS_MERGEABLE(bvprv, bvec))
442+
if (!biovec_phys_mergeable(bvprv, bvec))
443443
goto new_segment;
444444
if (!BIOVEC_SEG_BOUNDARY(q, bvprv, bvec))
445445
goto new_segment;

‎block/blk.h‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,20 @@ static inline void blk_queue_enter_live(struct request_queue *q)
149149
percpu_ref_get(&q->q_usage_counter);
150150
}
151151

152+
#ifndef ARCH_BIOVEC_PHYS_MERGEABLE
153+
#define ARCH_BIOVEC_PHYS_MERGEABLE(vec1, vec2) true
154+
#endif
155+
156+
static inline bool biovec_phys_mergeable(const struct bio_vec *vec1,
157+
const struct bio_vec *vec2)
158+
{
159+
if (bvec_to_phys(vec1) + vec1->bv_len != bvec_to_phys(vec2))
160+
return false;
161+
if (!ARCH_BIOVEC_PHYS_MERGEABLE(vec1, vec2))
162+
return false;
163+
return true;
164+
}
165+
152166
static inline bool __bvec_gap_to_prev(struct request_queue *q,
153167
struct bio_vec *bprv, unsigned int offset)
154168
{

‎include/linux/bio.h‎

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -140,19 +140,6 @@ static inline bool bio_full(struct bio *bio)
140140
/*
141141
* merge helpers etc
142142
*/
143-
144-
/* Default implementation of BIOVEC_PHYS_MERGEABLE */
145-
#define __BIOVEC_PHYS_MERGEABLE(vec1, vec2) \
146-
((bvec_to_phys((vec1)) + (vec1)->bv_len) == bvec_to_phys((vec2)))
147-
148-
/*
149-
* allow arch override, for eg virtualized architectures (put in asm/io.h)
150-
*/
151-
#ifndef BIOVEC_PHYS_MERGEABLE
152-
#define BIOVEC_PHYS_MERGEABLE(vec1, vec2) \
153-
__BIOVEC_PHYS_MERGEABLE(vec1, vec2)
154-
#endif
155-
156143
#define __BIO_SEG_BOUNDARY(addr1, addr2, mask) \
157144
(((addr1) | (mask)) == (((addr2) - 1) | (mask)))
158145
#define BIOVEC_SEG_BOUNDARY(q, b1, b2) \

0 commit comments

Comments
 (0)