clean up physical merging helpers V2
Subsystems (5)
Hi Jens,
this series moves various helpers related to merging based on physical addresses from the public headers into block/, cleans up the code a bit and removes not nessecary includes from the block headers.
Change since V1:
- dropped the Xen related changed which are moved into a new series to be sent after this one
PATCH 1/10 arm: remove the unused BIOVEC_MERGEABLE define
--- arch/arm/include/asm/io.h | 7 ------- 1 file changed, 7 deletions(-)
arch/arm/include/asm/io.h +0 -7
@@ -459,13 +459,6 @@ extern void pci_iounmap(struct pci_dev *dev, void __iomem *addr);#include <asm-generic/io.h> -/* -* can the hardware map this into one segment or not, given no other -* constraints. -*/ -#define BIOVEC_MERGEABLE (vec1, vec2) \ - ((bvec_to_phys((vec1)) + (vec1)->bv_len) == bvec_to_phys((vec2))) -struct bio_vec ;extern bool xen_biovec_phys_mergeable (const struct bio_vec *vec1,const struct bio_vec *vec2);
Signature · 1 line
2.19.0
PATCH 2/10 block: move integrity_req_gap_{back,front}_merge to blk.h
In reply to Christoph HellwigNo need to expose these to drivers.
--- block/blk.h | 35 +++++++++++++++++++++++++++++++++-- include/linux/blkdev.h | 31 ------------------------------- 2 files changed, 33 insertions(+), 33 deletions(-)
block/blk.h +33 -2
@@ -158,7 +158,38 @@ static inline bool bio_integrity_endio(struct bio *bio)return __bio_integrity_endio (bio);return true; } -#else + +static inline bool integrity_req_gap_back_merge (struct request *req, +struct bio *next) +{ +struct bio_integrity_payload *bip =bio_integrity (req->bio); +struct bio_integrity_payload *bip_next =bio_integrity (next); + +return bvec_gap_to_prev (req->q, &bip->bip_vec[bip->bip_vcnt -1 ], + bip_next->bip_vec[0 ].bv_offset); +} + +static inline bool integrity_req_gap_front_merge (struct request *req, +struct bio *bio) +{ +struct bio_integrity_payload *bip =bio_integrity (bio); +struct bio_integrity_payload *bip_next =bio_integrity (req->bio); + +return bvec_gap_to_prev (req->q, &bip->bip_vec[bip->bip_vcnt -1 ], + bip_next->bip_vec[0 ].bv_offset); +} +#else /* CONFIG_BLK_DEV_INTEGRITY */ +static inline bool integrity_req_gap_back_merge (struct request *req, +struct bio *next) +{ +return false; +} +static inline bool integrity_req_gap_front_merge (struct request *req, +struct bio *bio) +{ +return false; +} +static inline void blk_flush_integrity (void ) { }
@@ -166,7 +197,7 @@ static inline bool bio_integrity_endio(struct bio *bio) {return true; } -#endif +#endif /* CONFIG_BLK_DEV_INTEGRITY */ void blk_timeout_work (struct work_struct *work);unsigned long blk_rq_timeout (unsigned long timeout);
include/linux/blkdev.h +0 -31
@@ -1843,26 +1843,6 @@ queue_max_integrity_segments(struct request_queue *q)return q->limits.max_integrity_segments; } -static inline bool integrity_req_gap_back_merge (struct request *req, -struct bio *next) -{ -struct bio_integrity_payload *bip =bio_integrity (req->bio); -struct bio_integrity_payload *bip_next =bio_integrity (next); - -return bvec_gap_to_prev (req->q, &bip->bip_vec[bip->bip_vcnt -1 ], - bip_next->bip_vec[0 ].bv_offset); -} - -static inline bool integrity_req_gap_front_merge (struct request *req, -struct bio *bio) -{ -struct bio_integrity_payload *bip =bio_integrity (bio); -struct bio_integrity_payload *bip_next =bio_integrity (req->bio); - -return bvec_gap_to_prev (req->q, &bip->bip_vec[bip->bip_vcnt -1 ], - bip_next->bip_vec[0 ].bv_offset); -} -/** * bio_integrity_intervals - Return number of integrity intervals for a bio * @bi: blk_integrity profile for device
@@ -1947,17 +1927,6 @@ static inline bool blk_integrity_merge_bio(struct request_queue *rq,return true; } -static inline bool integrity_req_gap_back_merge (struct request *req, -struct bio *next) -{ -return false; -} -static inline bool integrity_req_gap_front_merge (struct request *req, -struct bio *bio) -{ -return false; -} -static inline unsigned int bio_integrity_intervals (struct blk_integrity *bi,unsigned int sectors) {
Signature · 1 line
2.19.0
PATCH 3/10 block: move req_gap_{back,front}_merge to blk-merge.c
In reply to Christoph HellwigKeep it close to the actual users instead of exposing the function to all drivers.
--- block/blk-merge.c | 65 +++++++++++++++++++++++++++++++++++++++ include/linux/blkdev.h | 69 ------------------------------------------ 2 files changed, 65 insertions(+), 69 deletions(-)
block/blk-merge.c +65 -0
@@ -12,6 +12,71 @@#include "blk.h" +/* +* Check if the two bvecs from two bios can be merged to one segment. If yes, +* no need to check gap between the two bios since the 1st bio and the 1st bvec +* in the 2nd bio can be handled in one segment. +*/ +static inline bool bios_segs_mergeable (struct request_queue *q, +struct bio *prev,struct bio_vec *prev_last_bv, +struct bio_vec *next_first_bv) +{ +if (!BIOVEC_PHYS_MERGEABLE (prev_last_bv, next_first_bv)) +return false; +if (!BIOVEC_SEG_BOUNDARY (q, prev_last_bv, next_first_bv)) +return false; +if (prev->bi_seg_back_size + next_first_bv->bv_len > +queue_max_segment_size (q)) +return false; +return true; +} + +static inline bool bio_will_gap (struct request_queue *q, +struct request *prev_rq,struct bio *prev,struct bio *next) +{ +struct bio_vec pb, nb; + +if (!bio_has_data (prev) || !queue_virt_boundary (q)) +return false; + +/* +* Don't merge if the 1st bio starts with non-zero offset, otherwise it +* is quite difficult to respect the sg gap limit. We work hard to +* merge a huge number of small single bios in case of mkfs. +*/ +if (prev_rq) +bio_get_first_bvec (prev_rq->bio, &pb); +else +bio_get_first_bvec (prev, &pb); +if (pb.bv_offset) +return true; + +/* +* We don't need to worry about the situation that the merged segment +* ends in unaligned virt boundary: +* +* - if 'pb' ends aligned, the merged segment ends aligned +* - if 'pb' ends unaligned, the next bio must include +* one single bvec of 'nb', otherwise the 'nb' can't +* merge with 'pb' +*/ +bio_get_last_bvec (prev, &pb); +bio_get_first_bvec (next, &nb); +if (bios_segs_mergeable (q, prev, &pb, &nb)) +return false; +return __bvec_gap_to_prev (q, &pb, nb.bv_offset); +} + +static inline bool req_gap_back_merge (struct request *req,struct bio *bio) +{ +return bio_will_gap (req->q, req, req->biotail, bio); +} + +static inline bool req_gap_front_merge (struct request *req,struct bio *bio) +{ +return bio_will_gap (req->q,NULL , bio, req->bio); +} + static struct bio *blk_bio_discard_split(struct request_queue *q, struct bio *bio, struct bio_set *bs,
include/linux/blkdev.h +0 -69
75 lines not on this page · raw message
Signature · 1 line
2.19.0
PATCH 4/10 block: move req_gap_back_merge to blk.h
In reply to Christoph HellwigNo need to expose these helpers outside the block layer.
--- block/blk.h | 19 +++++++++++++++++++ include/linux/blkdev.h | 19 ------------------- 2 files changed, 19 insertions(+), 19 deletions(-)
block/blk.h +19 -0
@@ -149,6 +149,25 @@ static inline void blk_queue_enter_live(struct request_queue *q)percpu_ref_get (&q->q_usage_counter); } +static inline bool __bvec_gap_to_prev (struct request_queue *q, +struct bio_vec *bprv,unsigned int offset) +{ +return offset || + ((bprv->bv_offset + bprv->bv_len) &queue_virt_boundary (q)); +} + +/* +* Check if adding a bio_vec after bprv with offset would create a gap in +* the SG list. Most drivers don't care about this, but some do. +*/ +static inline bool bvec_gap_to_prev (struct request_queue *q, +struct bio_vec *bprv,unsigned int offset) +{ +if (!queue_virt_boundary (q)) +return false; +return __bvec_gap_to_prev (q, bprv, offset); +} +#ifdef CONFIG_BLK_DEV_INTEGRITY void blk_flush_integrity (void );bool __bio_integrity_endio (struct bio *);
include/linux/blkdev.h +0 -19
@@ -1676,25 +1676,6 @@ static inline void put_dev_sector(Sector p)put_page (p.v); } -static inline bool __bvec_gap_to_prev (struct request_queue *q, -struct bio_vec *bprv,unsigned int offset) -{ -return offset || - ((bprv->bv_offset + bprv->bv_len) &queue_virt_boundary (q)); -} - -/* -* Check if adding a bio_vec after bprv with offset would create a gap in -* the SG list. Most drivers don't care about this, but some do. -*/ -static inline bool bvec_gap_to_prev (struct request_queue *q, -struct bio_vec *bprv,unsigned int offset) -{ -if (!queue_virt_boundary (q)) -return false; -return __bvec_gap_to_prev (q, bprv, offset); -} -int kblockd_schedule_work (struct work_struct *work);int kblockd_schedule_work_on (int cpu,struct work_struct *work);int kblockd_mod_delayed_work_on (int cpu,struct delayed_work *dwork,unsigned long delay);
Signature · 1 line
2.19.0
PATCH 5/10 block: simplify BIOVEC_PHYS_MERGEABLE
In reply to Christoph HellwigTurn 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.
--- arch/arm/include/asm/io.h | 5 ++--- arch/arm64/include/asm/io.h | 5 ++--- arch/x86/include/asm/io.h | 5 ++--- block/bio.c | 2 +- block/blk-integrity.c | 4 ++-- block/blk-merge.c | 10 +++++----- block/blk.h | 14 ++++++++++++++ include/linux/bio.h | 13 ------------- 8 files changed, 28 insertions(+), 30 deletions(-)
arch/arm/include/asm/io.h +2 -3
@@ -462,9 +462,8 @@ extern void pci_iounmap(struct pci_dev *dev, void __iomem *addr);struct bio_vec ;extern bool xen_biovec_phys_mergeable (const struct bio_vec *vec1,const struct bio_vec *vec2); -#define BIOVEC_PHYS_MERGEABLE (vec1, vec2) \ - (__BIOVEC_PHYS_MERGEABLE(vec1, vec2) && \ - (!xen_domain() || xen_biovec_phys_mergeable(vec1, vec2))) +#define ARCH_BIOVEC_PHYS_MERGEABLE (vec1, vec2) \ + (!xen_domain() || xen_biovec_phys_mergeable(vec1, vec2))#ifdef CONFIG_MMU #define ARCH_HAS_VALID_PHYS_ADDR_RANGE
arch/arm64/include/asm/io.h +2 -3
@@ -208,9 +208,8 @@ extern int devmem_is_allowed(unsigned long pfn);struct bio_vec ;extern bool xen_biovec_phys_mergeable (const struct bio_vec *vec1,const struct bio_vec *vec2); -#define BIOVEC_PHYS_MERGEABLE (vec1, vec2) \ - (__BIOVEC_PHYS_MERGEABLE(vec1, vec2) && \ - (!xen_domain() || xen_biovec_phys_mergeable(vec1, vec2))) +#define ARCH_BIOVEC_PHYS_MERGEABLE (vec1, vec2) \ + (!xen_domain() || xen_biovec_phys_mergeable(vec1, vec2))#endif /* __KERNEL__ */ #endif /* __ASM_IO_H */
arch/x86/include/asm/io.h +2 -3
@@ -376,9 +376,8 @@ struct bio_vec;extern bool xen_biovec_phys_mergeable (const struct bio_vec *vec1,const struct bio_vec *vec2); -#define BIOVEC_PHYS_MERGEABLE (vec1, vec2) \ - (__BIOVEC_PHYS_MERGEABLE(vec1, vec2) && \ - (!xen_domain() || xen_biovec_phys_mergeable(vec1, vec2))) +#define ARCH_BIOVEC_PHYS_MERGEABLE (vec1, vec2) \ + (!xen_domain() || xen_biovec_phys_mergeable(vec1, vec2))#endif /* CONFIG_XEN */ #define IO_SPACE_LIMIT 0xffff
block/bio.c +1 -1
@@ -731,7 +731,7 @@ int bio_add_pc_page(struct request_queue *q, struct bio *bio, struct page }/* If we may be able to merge these biovecs, force a recount */ -if (bio->bi_vcnt >1 && (BIOVEC_PHYS_MERGEABLE (bvec-1 , bvec))) +if (bio->bi_vcnt >1 &&biovec_phys_mergeable (bvec-1 , bvec))bio_clear_flag (bio,BIO_SEG_VALID ); done:
block/blk-integrity.c +2 -2
@@ -49,7 +49,7 @@ int blk_rq_count_integrity_sg(struct request_queue *q, struct bio *bio)bio_for_each_integrity_vec (iv, bio, iter) {if (prev) { -if (!BIOVEC_PHYS_MERGEABLE (&ivprv, &iv)) +if (!biovec_phys_mergeable (&ivprv, &iv)) goto new_segment;if (!BIOVEC_SEG_BOUNDARY (q, &ivprv, &iv))
@@ -95,7 +95,7 @@ int blk_rq_map_integrity_sg(struct request_queue *q, struct bio *bio,bio_for_each_integrity_vec (iv, bio, iter) {if (prev) { -if (!BIOVEC_PHYS_MERGEABLE (&ivprv, &iv)) +if (!biovec_phys_mergeable (&ivprv, &iv)) goto new_segment;if (!BIOVEC_SEG_BOUNDARY (q, &ivprv, &iv))
block/blk-merge.c +5 -5
@@ -21,7 +21,7 @@ static inline bool bios_segs_mergeable(struct request_queue *q, struct bio *prev, struct bio_vec *prev_last_bv, struct bio_vec *next_first_bv) { - if (!BIOVEC_PHYS_MERGEABLE(prev_last_bv, next_first_bv)) + if (!biovec_phys_mergeable(prev_last_bv, next_first_bv)) return false;if (!BIOVEC_SEG_BOUNDARY (q, prev_last_bv, next_first_bv))return false;
@@ -199,7 +199,7 @@ static struct bio *blk_bio_segment_split(struct request_queue *q,if (bvprvp &&blk_queue_cluster (q)) {if (seg_size + bv.bv_len >queue_max_segment_size (q)) goto new_segment; -if (!BIOVEC_PHYS_MERGEABLE (bvprvp, &bv)) +if (!biovec_phys_mergeable (bvprvp, &bv)) goto new_segment;if (!BIOVEC_SEG_BOUNDARY (q, bvprvp, &bv)) goto new_segment;
@@ -332,7 +332,7 @@ static unsigned int __blk_recalc_rq_segments(struct request_queue *q,if (seg_size + bv.bv_len >queue_max_segment_size (q)) goto new_segment; -if (!BIOVEC_PHYS_MERGEABLE (&bvprv, &bv)) +if (!biovec_phys_mergeable (&bvprv, &bv)) goto new_segment;if (!BIOVEC_SEG_BOUNDARY (q, &bvprv, &bv)) goto new_segment;
@@ -414,7 +414,7 @@ static int blk_phys_contig_segment(struct request_queue *q, struct bio *bio,bio_get_last_bvec (bio, &end_bv);bio_get_first_bvec (nxt, &nxt_bv); -if (!BIOVEC_PHYS_MERGEABLE (&end_bv, &nxt_bv)) +if (!biovec_phys_mergeable (&end_bv, &nxt_bv))return 0 ;/*
@@ -439,7 +439,7 @@ __blk_segment_map_sg(struct request_queue *q, struct bio_vec *bvec,if ((*sg)->length + nbytes >queue_max_segment_size (q)) goto new_segment; -if (!BIOVEC_PHYS_MERGEABLE (bvprv, bvec)) +if (!biovec_phys_mergeable (bvprv, bvec)) goto new_segment;if (!BIOVEC_SEG_BOUNDARY (q, bvprv, bvec)) goto new_segment;
block/blk.h +14 -0
@@ -149,6 +149,20 @@ static inline void blk_queue_enter_live(struct request_queue *q)percpu_ref_get (&q->q_usage_counter); } +#ifndef ARCH_BIOVEC_PHYS_MERGEABLE +#define ARCH_BIOVEC_PHYS_MERGEABLE (vec1, vec2) true +#endif + +static inline bool biovec_phys_mergeable (const struct bio_vec *vec1, +const struct bio_vec *vec2) +{ +if (bvec_to_phys (vec1) + vec1->bv_len !=bvec_to_phys (vec2)) +return false; +if (!ARCH_BIOVEC_PHYS_MERGEABLE (vec1, vec2)) +return false; +return true; +} +static inline bool __bvec_gap_to_prev (struct request_queue *q,struct bio_vec *bprv,unsigned int offset) {
include/linux/bio.h +0 -13
@@ -140,19 +140,6 @@ static inline bool bio_full(struct bio *bio)/* * merge helpers etc */ - -/* Default implementation of BIOVEC_PHYS_MERGEABLE */ -#define __BIOVEC_PHYS_MERGEABLE (vec1, vec2) \ - ((bvec_to_phys((vec1)) + (vec1)->bv_len) == bvec_to_phys((vec2))) - -/* -* allow arch override, for eg virtualized architectures (put in asm/io.h) -*/ -#ifndef BIOVEC_PHYS_MERGEABLE -#define BIOVEC_PHYS_MERGEABLE (vec1, vec2) \ - __BIOVEC_PHYS_MERGEABLE(vec1, vec2) -#endif -#define __BIO_SEG_BOUNDARY (addr1, addr2, mask) \ (((addr1) | (mask)) == (((addr2) - 1) | (mask)))#define BIOVEC_SEG_BOUNDARY (q, b1, b2) \
Signature · 1 line
2.19.0
PATCH 6/10 block: add a missing BIOVEC_SEG_BOUNDARY check in bio_add_pc_page
In reply to Christoph HellwigThe actual recaculation of segments in __blk_recalc_rq_segments will do this check, so there is no point in forcing it if we know it won't succeed.
--- block/bio.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
block/bio.c +3 -1
@@ -731,7 +731,9 @@ int bio_add_pc_page(struct request_queue *q, struct bio *bio, struct page }/* If we may be able to merge these biovecs, force a recount */ -if (bio->bi_vcnt >1 &&biovec_phys_mergeable (bvec-1 , bvec)) +if (bio->bi_vcnt >1 && +biovec_phys_mergeable (bvec -1 , bvec) && +BIOVEC_SEG_BOUNDARY (q, bvec -1 , bvec))bio_clear_flag (bio,BIO_SEG_VALID ); done:
Signature · 1 line
2.19.0
PATCH 7/10 block: merge BIOVEC_SEG_BOUNDARY into biovec_phys_mergeable
In reply to Christoph HellwigThese two checks should always be performed together, so merge them into a single helper.
--- block/bio.c | 4 +--- block/blk-integrity.c | 12 ++---------- block/blk-merge.c | 29 +++++------------------------ block/blk.h | 12 +++++++++--- include/linux/bio.h | 8 -------- 5 files changed, 17 insertions(+), 48 deletions(-)
block/bio.c +1 -3
@@ -731,9 +731,7 @@ int bio_add_pc_page(struct request_queue *q, struct bio *bio, struct page }/* If we may be able to merge these biovecs, force a recount */ -if (bio->bi_vcnt >1 && -biovec_phys_mergeable (bvec -1 , bvec) && -BIOVEC_SEG_BOUNDARY (q, bvec -1 , bvec)) +if (bio->bi_vcnt >1 &&biovec_phys_mergeable (q, bvec -1 , bvec))bio_clear_flag (bio,BIO_SEG_VALID ); done:
block/blk-integrity.c +2 -10
@@ -49,12 +49,8 @@ int blk_rq_count_integrity_sg(struct request_queue *q, struct bio *bio)bio_for_each_integrity_vec (iv, bio, iter) {if (prev) { -if (!biovec_phys_mergeable (&ivprv, &iv)) +if (!biovec_phys_mergeable (q, &ivprv, &iv)) goto new_segment; - -if (!BIOVEC_SEG_BOUNDARY (q, &ivprv, &iv)) - goto new_segment; -if (seg_size + iv.bv_len >queue_max_segment_size (q)) goto new_segment;
@@ -95,12 +91,8 @@ int blk_rq_map_integrity_sg(struct request_queue *q, struct bio *bio,bio_for_each_integrity_vec (iv, bio, iter) {if (prev) { -if (!biovec_phys_mergeable (&ivprv, &iv)) +if (!biovec_phys_mergeable (q, &ivprv, &iv)) goto new_segment; - -if (!BIOVEC_SEG_BOUNDARY (q, &ivprv, &iv)) - goto new_segment; -if (sg->length + iv.bv_len >queue_max_segment_size (q)) goto new_segment;
block/blk-merge.c +5 -24
@@ -21,9 +21,7 @@ static inline bool bios_segs_mergeable(struct request_queue *q, struct bio *prev, struct bio_vec *prev_last_bv, struct bio_vec *next_first_bv) { - if (!biovec_phys_mergeable(prev_last_bv, next_first_bv)) - return false; -if (!BIOVEC_SEG_BOUNDARY (q, prev_last_bv, next_first_bv)) + if (!biovec_phys_mergeable(q, prev_last_bv, next_first_bv)) return false;if (prev->bi_seg_back_size + next_first_bv->bv_len >queue_max_segment_size (q))
@@ -199,9 +197,7 @@ static struct bio *blk_bio_segment_split(struct request_queue *q,if (bvprvp &&blk_queue_cluster (q)) {if (seg_size + bv.bv_len >queue_max_segment_size (q)) goto new_segment; -if (!biovec_phys_mergeable (bvprvp, &bv)) - goto new_segment; -if (!BIOVEC_SEG_BOUNDARY (q, bvprvp, &bv)) +if (!biovec_phys_mergeable (q, bvprvp, &bv)) goto new_segment; seg_size += bv.bv_len;
@@ -332,9 +328,7 @@ static unsigned int __blk_recalc_rq_segments(struct request_queue *q,if (seg_size + bv.bv_len >queue_max_segment_size (q)) goto new_segment; -if (!biovec_phys_mergeable (&bvprv, &bv)) - goto new_segment; -if (!BIOVEC_SEG_BOUNDARY (q, &bvprv, &bv)) +if (!biovec_phys_mergeable (q, &bvprv, &bv)) goto new_segment; seg_size += bv.bv_len;
@@ -414,17 +408,7 @@ static int blk_phys_contig_segment(struct request_queue *q, struct bio *bio,bio_get_last_bvec (bio, &end_bv);bio_get_first_bvec (nxt, &nxt_bv); -if (!biovec_phys_mergeable (&end_bv, &nxt_bv)) -return 0 ; - -/* -* bio and nxt are contiguous in memory; check if the queue allows -* these two to be merged into one -*/ -if (BIOVEC_SEG_BOUNDARY (q, &end_bv, &nxt_bv)) -return 1 ; - -return 0 ; +return biovec_phys_mergeable (q, &end_bv, &nxt_bv); } static inline void
@@ -438,10 +422,7 @@ __blk_segment_map_sg(struct request_queue *q, struct bio_vec *bvec,if (*sg && *cluster) {if ((*sg)->length + nbytes >queue_max_segment_size (q)) goto new_segment; - -if (!biovec_phys_mergeable (bvprv, bvec)) - goto new_segment; -if (!BIOVEC_SEG_BOUNDARY (q, bvprv, bvec)) +if (!biovec_phys_mergeable (q, bvprv, bvec)) goto new_segment; (*sg)->length += nbytes;
block/blk.h +9 -3
@@ -153,13 +153,19 @@ static inline void blk_queue_enter_live(struct request_queue *q)#define ARCH_BIOVEC_PHYS_MERGEABLE (vec1, vec2) true#endif -static inline bool biovec_phys_mergeable (const struct bio_vec *vec1, -const struct bio_vec *vec2) +static inline bool biovec_phys_mergeable (struct request_queue *q, +struct bio_vec *vec1,struct bio_vec *vec2) { -if (bvec_to_phys (vec1) + vec1->bv_len !=bvec_to_phys (vec2)) +unsigned long mask =queue_segment_boundary (q); +phys_addr_t addr1 =bvec_to_phys (vec1); +phys_addr_t addr2 =bvec_to_phys (vec2); + +if (addr1 + vec1->bv_len != addr2)return false;if (!ARCH_BIOVEC_PHYS_MERGEABLE (vec1, vec2))return false; +if ((addr1 | mask) != ((addr2 + vec2->bv_len -1 ) | mask)) +return false;return true; }
include/linux/bio.h +0 -8
@@ -137,14 +137,6 @@ static inline bool bio_full(struct bio *bio)*/ #define bvec_to_phys (bv) (page_to_phys((bv)->bv_page) + (unsigned long) (bv)->bv_offset) -/* -* merge helpers etc -*/ -#define __BIO_SEG_BOUNDARY (addr1, addr2, mask) \ - (((addr1) | (mask)) == (((addr2) - 1) | (mask))) -#define BIOVEC_SEG_BOUNDARY (q, b1, b2) \ - __BIO_SEG_BOUNDARY(bvec_to_phys((b1)), bvec_to_phys((b2)) + (b2)->bv_len, queue_segment_boundary((q))) -/* * drivers should _never_ use the all version - the bio may have been split * before it got to the driver and the driver won't own all of it
Signature · 1 line
2.19.0
PATCH 8/10 block: remove bvec_to_phys
In reply to Christoph HellwigWe only use it in biovec_phys_mergeable and a m68k paravirt driver, so just opencode it there. Also remove the pointless unsigned long cast for the offset in the opencoded instances.
--- arch/m68k/emu/nfblock.c | 2 +- block/blk.h | 4 ++-- include/linux/bio.h | 5 ----- 3 files changed, 3 insertions(+), 8 deletions(-)
arch/m68k/emu/nfblock.c +1 -1
@@ -73,7 +73,7 @@ static blk_qc_t nfhd_make_request(struct request_queue *queue, struct bio *bio) len = bvec.bv_len; len >>=9 ;nfhd_read_write (dev->id,0 , dir, sec >> shift, len >> shift, -bvec_to_phys (&bvec)); +page_to_phys (bvec.bv_page) + bvec.bv_offset); sec += len; }bio_endio (bio);
block/blk.h +2 -2
@@ -157,8 +157,8 @@ static inline bool biovec_phys_mergeable(struct request_queue *q, struct bio_vec *vec1, struct bio_vec *vec2) { unsigned long mask = queue_segment_boundary(q); -phys_addr_t addr1 =bvec_to_phys (vec1); -phys_addr_t addr2 =bvec_to_phys (vec2); +phys_addr_t addr1 =page_to_phys (vec1->bv_page) + vec1->bv_offset; +phys_addr_t addr2 =page_to_phys (vec2->bv_page) + vec2->bv_offset;if (addr1 + vec1->bv_len != addr2)return false;
include/linux/bio.h +0 -5
@@ -132,11 +132,6 @@ static inline bool bio_full(struct bio *bio)return bio->bi_vcnt >= bio->bi_max_vecs; } -/* -* will die -*/ -#define bvec_to_phys (bv) (page_to_phys((bv)->bv_page) + (unsigned long) (bv)->bv_offset) -/* * drivers should _never_ use the all version - the bio may have been split * before it got to the driver and the driver won't own all of it
Signature · 1 line
2.19.0
PATCH 9/10 block: don't include io.h from bio.h
In reply to Christoph HellwigNow that we don't need an override for BIOVEC_PHYS_MERGEABLE there is no need to drag this header in.
--- include/linux/bio.h | 3 --- 1 file changed, 3 deletions(-)
include/linux/bio.h +0 -3
@@ -24,9 +24,6 @@#include <linux/bug.h> #ifdef CONFIG_BLOCK - -#include <asm/io.h> -/* struct bio, bio_vec and BIO_* flags are defined in blk_types.h */ #include <linux/blk_types.h>
Signature · 1 line
2.19.0
PATCH 10/10 block: don't include bug.h from bio.h
In reply to Christoph HellwigNo need to pull in the BUG() defintion.
--- include/linux/bio.h | 1 - 1 file changed, 1 deletion(-)
include/linux/bio.h +0 -1
@@ -21,7 +21,6 @@#include <linux/highmem.h> #include <linux/mempool.h> #include <linux/ioprio.h> -#include <linux/bug.h> #ifdef CONFIG_BLOCK /* struct bio, bio_vec and BIO_* flags are defined in blk_types.h */
Signature · 1 line
2.19.0
Jens Axboe
maintainerQuoted 9 lines · Christoph Hellwig
Hi Jens,
this series moves various helpers related to merging based on physical addresses from the public headers into
block/, cleans up the code a bit and removes not nessecary includes from the block headers.Change since V1:
- dropped the Xen related changed which are moved into a new series to be sent after this one
Looks good to me - #1 should just go to the arm guys separately, there's no point in me carrying this arch patch.
Signature · 1 line
Jens Axboe
Quoted 2 lines · Jens Axboe
Looks good to me - #1 should just go to the arm guys separately, there's no point in me carrying this arch patch.
It would require a respin of all the Xen patches and is rather related. But if you absolutely don't want it I can drop it from the resend of those.
Jens Axboe
maintainerQuoted 7 lines · Christoph Hellwig
Quoted 2 lines · Jens Axboe
Looks good to me - #1 should just go to the arm guys separately, there's no point in me carrying this arch patch.
It would require a respin of all the Xen patches and is rather related. But if you absolutely don't want it I can drop it from the resend of those.
I don't feel that strongly about it, and it's dead block code. If it makes your life easier, I can add it.
Signature · 1 line
Jens Axboe
Ming Lei
Reviewed-byQuoted 9 lines · Christoph Hellwig
Hi Jens,
this series moves various helpers related to merging based on physical addresses from the public headers into
block/, cleans up the code a bit and removes not nessecary includes from the block headers.Change since V1:
- dropped the Xen related changed which are moved into a new series to be sent after this one
Looks fine:
Thanks,
Ming