decruft bio.h
Hi Jens,
this series moves various declarations that do not need to be global out of bio.h.
Diffstat:
block/bio.c | 100 ++++++++++++++++++++++++++++--------------------- block/blk-merge.c | 31 +++++++++++++++ block/blk-mq-sched.h | 5 ++ include/linux/bio.h | 78 -------------------------------------- include/linux/blk-mq.h | 6 ++ 5 files changed, 99 insertions(+), 121 deletions(-)
PATCH 1/8 block: remove BIO_BUG_ON
BIO_DEBUG is always defined, so just switch the two instances to use BUG_ON directly.
--- block/bio.c | 4 ++-- include/linux/bio.h | 8 -------- 2 files changed, 2 insertions(+), 10 deletions(-)
block/bio.c +2 -2
@@ -156,7 +156,7 @@ static void bio_put_slab(struct bio_set *bs)void bvec_free (mempool_t *pool,struct bio_vec *bv,unsigned short nr_vecs) { -BIO_BUG_ON (nr_vecs >BIO_MAX_VECS ); +BUG_ON (nr_vecs >BIO_MAX_VECS );if (nr_vecs ==BIO_MAX_VECS )mempool_free (bv, pool);
@@ -677,7 +677,7 @@ static void bio_alloc_cache_destroy(struct bio_set *bs)void bio_put (struct bio *bio) {if (unlikely (bio_flagged (bio,BIO_REFFED ))) { -BIO_BUG_ON (!atomic_read (&bio->__bi_cnt)); +BUG_ON (!atomic_read (&bio->__bi_cnt));if (!atomic_dec_and_test (&bio->__bi_cnt))return ; }
include/linux/bio.h +0 -8
@@ -11,14 +11,6 @@#include <linux/blk_types.h> #include <linux/uio.h> -#define BIO_DEBUG - -#ifdef BIO_DEBUG -#define BIO_BUG_ON BUG_ON -#else -#define BIO_BUG_ON -#endif -#define BIO_MAX_VECS 256Ustatic inline unsigned int bio_max_segs (unsigned int nr_segs)
Signature · 1 line
2.30.2
Re: [PATCH 1/8] block: remove BIO_BUG_ON
Quoted 4 lines · Christoph Hellwig
BIO_DEBUGis always defined, so just switch the two instances to useBUG_ONdirectly.Signed-off-by Christoph Hellwig <[email protected]>
Looks good.
PATCH 2/8 block: don't include <linux/ioprio.h> in <linux/bio.h>
In reply to Christoph Hellwigbio.h doesn't need any of the definitions from ioprio.h.
--- include/linux/bio.h | 1 - 1 file changed, 1 deletion(-)
include/linux/bio.h +0 -1
@@ -6,7 +6,6 @@#define __LINUX_BIO_H#include <linux/mempool.h> -#include <linux/ioprio.h> /* struct bio, bio_vec and BIO_* flags are defined in blk_types.h */ #include <linux/blk_types.h> #include <linux/uio.h>
Signature · 1 line
2.30.2
Re: [PATCH 2/8] block: don't include <linux/ioprio.h> in <linux/bio.h>
Quoted 4 lines · Christoph Hellwig
bio.hdoesn't need any of the definitions fromioprio.h.Signed-off-by Christoph Hellwig <[email protected]>---
Looks good.
PATCH 3/8 block: move bio_mergeable out of bio.h
In reply to Christoph Hellwigbio_mergeable is only needed by I/O schedulers, so move it to blk-mq-sched.h.
--- block/blk-mq-sched.h | 5 +++++ include/linux/bio.h | 8 -------- 2 files changed, 5 insertions(+), 8 deletions(-)
block/blk-mq-sched.h +5 -0
@@ -31,6 +31,11 @@ int blk_mq_init_sched(struct request_queue *q, struct elevator_type *e);void blk_mq_exit_sched (struct request_queue *q,struct elevator_queue *e);void blk_mq_sched_free_rqs (struct request_queue *q); +static inline bool bio_mergeable (struct bio *bio) +{ +return !(bio->bi_opf &REQ_NOMERGE_FLAGS ); +} +static inline bool blk_mq_sched_bio_merge (struct request_queue *q,struct bio *bio,unsigned int nr_segs)
include/linux/bio.h +0 -8
@@ -69,14 +69,6 @@ static inline bool bio_no_advance_iter(const struct bio *bio)bio_op (bio) ==REQ_OP_WRITE_ZEROES ; } -static inline bool bio_mergeable (struct bio *bio) -{ -if (bio->bi_opf &REQ_NOMERGE_FLAGS ) -return false; - -return true; -} -static inline unsigned int bio_cur_bytes (struct bio *bio) {if (bio_has_data (bio))
Signature · 1 line
2.30.2
Re: [PATCH 3/8] block: move bio_mergeable out of bio.h
Quoted 5 lines · Christoph Hellwig
bio_mergeableis only needed by I/O schedulers, so move it toblk-mq-sched.h.Signed-off-by Christoph Hellwig <[email protected]>---
Looks good.
PATCH 4/8 block: fold bio_cur_bytes into blk_rq_cur_bytes
In reply to Christoph HellwigFold bio_cur_bytes into the only caller.
--- include/linux/bio.h | 8 -------- include/linux/blk-mq.h | 6 +++++- 2 files changed, 5 insertions(+), 9 deletions(-)
include/linux/bio.h +0 -8
@@ -69,14 +69,6 @@ static inline bool bio_no_advance_iter(const struct bio *bio)bio_op (bio) ==REQ_OP_WRITE_ZEROES ; } -static inline unsigned int bio_cur_bytes (struct bio *bio) -{ -if (bio_has_data (bio)) -return bio_iovec (bio).bv_len; -else /* dataless requests such as discard */ -return bio->bi_iter.bi_size; -} -static inline void *bio_data (struct bio *bio) {if (bio_has_data (bio))
include/linux/blk-mq.h +5 -1
@@ -927,7 +927,11 @@ static inline unsigned int blk_rq_bytes(const struct request *rq)static inline int blk_rq_cur_bytes (const struct request *rq) { -return rq->bio ?bio_cur_bytes (rq->bio) :0 ; +if (!rq->bio) +return 0 ; +if (!bio_has_data (rq->bio))/* dataless requests such as discard */ +return rq->bio->bi_iter.bi_size; +return bio_iovec (rq->bio).bv_len; }unsigned int blk_rq_err_bytes (const struct request *rq);
Signature · 1 line
2.30.2
Re: [PATCH 4/8] block: fold bio_cur_bytes into blk_rq_cur_bytes
Quoted 4 lines · Christoph Hellwig
Fold
bio_cur_bytesinto the only caller.Signed-off-by Christoph Hellwig <[email protected]>---
Looks good.
PATCH 5/8 block: move bio_full out of bio.h
In reply to Christoph Hellwigbio_full is only used in bio.c, so move it there.
--- block/bio.c | 17 +++++++++++++++++ include/linux/bio.h | 19 ------------------- 2 files changed, 17 insertions(+), 19 deletions(-)
block/bio.c +17 -0
@@ -772,6 +772,23 @@ const char *bio_devname(struct bio *bio, char *buf) }EXPORT_SYMBOL (bio_devname); +/** +* bio_full - check if the bio is full +* @bio: bio to check +* @len: length of one segment to be added +* +* Return true if @bio is full and one segment with @len bytes can't be +* added to the bio, otherwise return false +*/ +static inline bool bio_full (struct bio *bio,unsigned len) +{ +if (bio->bi_vcnt >= bio->bi_max_vecs) +return true; +if (bio->bi_iter.bi_size >UINT_MAX - len) +return true; +return false; +} +static inline bool page_is_mergeable (const struct bio_vec *bv,struct page *page,unsigned int len,unsigned int off,bool *same_page)
include/linux/bio.h +0 -19
@@ -77,25 +77,6 @@ static inline void *bio_data(struct bio *bio)return NULL ; } -/** -* bio_full - check if the bio is full -* @bio: bio to check -* @len: length of one segment to be added -* -* Return true if @bio is full and one segment with @len bytes can't be -* added to the bio, otherwise return false -*/ -static inline bool bio_full (struct bio *bio,unsigned len) -{ -if (bio->bi_vcnt >= bio->bi_max_vecs) -return true; - -if (bio->bi_iter.bi_size >UINT_MAX - len) -return true; - -return false; -} -static inline bool bio_next_segment (const struct bio *bio,struct bvec_iter_all *iter) {
Signature · 1 line
2.30.2
Re: [PATCH 5/8] block: move bio_full out of bio.h
Quoted 4 lines · Christoph Hellwig
bio_fullis only used inbio.c, so move it there.Signed-off-by Christoph Hellwig <[email protected]>---
Looks good.
PATCH 6/8 block: mark __bio_try_merge_page static
In reply to Christoph HellwigMark __bio_try_merge_page static and move it up a bit to avoid the need for a forward declaration.
--- block/bio.c | 77 ++++++++++++++++++++++----------------------- include/linux/bio.h | 2 -- 2 files changed, 38 insertions(+), 41 deletions(-)
block/bio.c +38 -39
@@ -808,6 +808,44 @@ static inline bool page_is_mergeable(const struct bio_vec *bv,return (bv->bv_page + bv_end /PAGE_SIZE ) == (page + off /PAGE_SIZE ); } +/** +* __bio_try_merge_page - try appending data to an existing bvec. +* @bio: destination bio +* @page: start page to add +* @len: length of the data to add +* @off: offset of the data relative to @page +* @same_page: return if the segment has been merged inside the same page +* +* Try to add the data at @page + @off to the last bvec of @bio. This is a +* useful optimisation for file systems with a block size smaller than the +* page size. +* +* Warn if (@len, @off) crosses pages in case that @same_page is true. +* +* Return %true on success or %false on failure. +*/ +static bool __bio_try_merge_page (struct bio *bio,struct page *page, +unsigned int len,unsigned int off,bool *same_page) +{ +if (WARN_ON_ONCE (bio_flagged (bio,BIO_CLONED ))) +return false; + +if (bio->bi_vcnt >0 ) { +struct bio_vec *bv = &bio->bi_io_vec[bio->bi_vcnt -1 ]; + +if (page_is_mergeable (bv, page, len, off, same_page)) { +if (bio->bi_iter.bi_size >UINT_MAX - len) { + *same_page = false; +return false; + } + bv->bv_len += len; + bio->bi_iter.bi_size += len; +return true; + } + } +return false; +} +/* * Try to merge a page into a segment, while obeying the hardware segment * size limit. This is not for normal read/write bios, but for passthrough
@@ -939,45 +977,6 @@ int bio_add_zone_append_page(struct bio *bio, struct page *page, }EXPORT_SYMBOL_GPL (bio_add_zone_append_page); -/** -* __bio_try_merge_page - try appending data to an existing bvec. -* @bio: destination bio -* @page: start page to add -* @len: length of the data to add -* @off: offset of the data relative to @page -* @same_page: return if the segment has been merged inside the same page -* -* Try to add the data at @page + @off to the last bvec of @bio. This is a -* useful optimisation for file systems with a block size smaller than the -* page size. -* -* Warn if (@len, @off) crosses pages in case that @same_page is true. -* -* Return %true on success or %false on failure. -*/ -bool __bio_try_merge_page (struct bio *bio,struct page *page, -unsigned int len,unsigned int off,bool *same_page) -{ -if (WARN_ON_ONCE (bio_flagged (bio,BIO_CLONED ))) -return false; - -if (bio->bi_vcnt >0 ) { -struct bio_vec *bv = &bio->bi_io_vec[bio->bi_vcnt -1 ]; - -if (page_is_mergeable (bv, page, len, off, same_page)) { -if (bio->bi_iter.bi_size >UINT_MAX - len) { - *same_page = false; -return false; - } - bv->bv_len += len; - bio->bi_iter.bi_size += len; -return true; - } - } -return false; -} -EXPORT_SYMBOL_GPL (__bio_try_merge_page); -/** * __bio_add_page - add page(s) to a bio in a new segment * @bio: destination bio
include/linux/bio.h +0 -2
@@ -425,8 +425,6 @@ extern int bio_add_pc_page(struct request_queue *, struct bio *, struct page *, unsigned int, unsigned int);int bio_add_zone_append_page (struct bio *bio,struct page *page,unsigned int len,unsigned int offset); -bool __bio_try_merge_page (struct bio *bio,struct page *page, -unsigned int len,unsigned int off,bool *same_page);void __bio_add_page (struct bio *bio,struct page *page,unsigned int len,unsigned int off);int bio_iov_iter_get_pages (struct bio *bio,struct iov_iter *iter);
Signature · 1 line
2.30.2
Re: [PATCH 6/8] block: mark __bio_try_merge_page static
Quoted 4 lines · Christoph Hellwig
Mark
__bio_try_merge_pagestatic and move it up a bit to avoid the need for a forward declaration.Signed-off-by Christoph Hellwig <[email protected]>
Looks good.
PATCH 7/8 block: move bio_get_{first,last}_bvec out of bio.h
In reply to Christoph Hellwigbio_get_first_bvec and bio_get_last_bvec are only used in blk-merge.c, so move them there.
--- block/blk-merge.c | 31 +++++++++++++++++++++++++++++++ include/linux/bio.h | 31 ------------------------------- 2 files changed, 31 insertions(+), 31 deletions(-)
block/blk-merge.c +31 -0
@@ -15,6 +15,37 @@#include "blk-rq-qos.h" #include "blk-throttle.h" +static inline void bio_get_first_bvec (struct bio *bio,struct bio_vec *bv) +{ + *bv =mp_bvec_iter_bvec (bio->bi_io_vec, bio->bi_iter); +} + +static inline void bio_get_last_bvec (struct bio *bio,struct bio_vec *bv) +{ +struct bvec_iter iter = bio->bi_iter; +int idx; + +bio_get_first_bvec (bio, bv); +if (bv->bv_len == bio->bi_iter.bi_size) +return ;/* this bio only has a single bvec */ + +bio_advance_iter (bio, &iter, iter.bi_size); + +if (!iter.bi_bvec_done) + idx = iter.bi_idx -1 ; +else /* in the middle of bvec */ + idx = iter.bi_idx; + + *bv = bio->bi_io_vec[idx]; + +/* +* iter.bi_bvec_done records actual length of the last bvec +* if this bio ends in the middle of one io vector +*/ +if (iter.bi_bvec_done) + bv->bv_len = iter.bi_bvec_done; +} +static inline bool bio_will_gap (struct request_queue *q,struct request *prev_rq,struct bio *prev,struct bio *next) {
include/linux/bio.h +0 -31
@@ -221,37 +221,6 @@ static inline void bio_clear_flag(struct bio *bio, unsigned int bit) bio->bi_flags &= ~(1U << bit); } -static inline void bio_get_first_bvec (struct bio *bio,struct bio_vec *bv) -{ - *bv =mp_bvec_iter_bvec (bio->bi_io_vec, bio->bi_iter); -} - -static inline void bio_get_last_bvec (struct bio *bio,struct bio_vec *bv) -{ -struct bvec_iter iter = bio->bi_iter; -int idx; - -bio_get_first_bvec (bio, bv); -if (bv->bv_len == bio->bi_iter.bi_size) -return ;/* this bio only has a single bvec */ - -bio_advance_iter (bio, &iter, iter.bi_size); - -if (!iter.bi_bvec_done) - idx = iter.bi_idx -1 ; -else /* in the middle of bvec */ - idx = iter.bi_idx; - - *bv = bio->bi_io_vec[idx]; - -/* -* iter.bi_bvec_done records actual length of the last bvec -* if this bio ends in the middle of one io vector -*/ -if (iter.bi_bvec_done) - bv->bv_len = iter.bi_bvec_done; -} -static inline struct bio_vec *bio_first_bvec_all (struct bio *bio) {WARN_ON_ONCE (bio_flagged (bio,BIO_CLONED ));
Signature · 1 line
2.30.2
Re: [PATCH 7/8] block: move bio_get_{first,last}_bvec out of bio.h
Quoted 4 lines · Christoph Hellwig
bio_get_first_bvecandbio_get_last_bvecare only used inblk-merge.c, so move them there.Signed-off-by Christoph Hellwig <[email protected]>
Looks good.
PATCH 8/8 block: mark bio_truncate static
In reply to Christoph Hellwigbio_truncate is only used in bio.c, so mark it static.
--- block/bio.c | 2 +- include/linux/bio.h | 1 - 2 files changed, 1 insertion(+), 2 deletions(-)
block/bio.c +1 -1
@@ -546,7 +546,7 @@ EXPORT_SYMBOL(zero_fill_bio);* REQ_OP_READ, zero the truncated part. This function should only * be used for handling corner cases, such as bio eod. */ -void bio_truncate (struct bio *bio,unsigned new_size) +static void bio_truncate (struct bio *bio,unsigned new_size) {struct bio_vec bv;struct bvec_iter iter;
include/linux/bio.h +0 -1
@@ -405,7 +405,6 @@ extern void bio_copy_data_iter(struct bio *dst, struct bvec_iter *dst_iter, struct bio *src, struct bvec_iter *src_iter);extern void bio_copy_data (struct bio *dst,struct bio *src);extern void bio_free_pages (struct bio *bio); -void bio_truncate (struct bio *bio,unsigned new_size);void guard_bio_eod (struct bio *bio);void zero_fill_bio (struct bio *bio);
Signature · 1 line
2.30.2
Re: [PATCH 8/8] block: mark bio_truncate static
Quoted 3 lines · Christoph Hellwig
bio_truncateis only used inbio.c, so mark it static.Signed-off-by Christoph Hellwig <[email protected]>
Looks good.
Quoted 4 lines · Christoph Hellwig
this series moves various declarations that do not need to be global out of
bio.h.Diffstat:
Quoted 8 lines
block/bio.c | 100 ++++++++++++++++++++++++++++--------------------- block/blk-merge.c | 31 +++++++++++++++ block/blk-mq-sched.h | 5 ++ include/linux/bio.h | 78 -------------------------------------- include/linux/blk-mq.h | 6 ++ 5 files changed, 99 insertions(+), 121 deletions(-)[...]
Applied, thanks!
[1/8] block: remove BIO_BUG_ON
commit: 50c1c0fdacf093dca591e36db62ffa5b68db2ba5
[2/8] block: don't include <linux/ioprio.h> in <linux/bio.h>
commit: 572f1bca6dfd38d5bf27bb617cffbd4788adaa16
[3/8] block: move bio_mergeable out of bio.h
commit: 272ff6fb565b310b436f3348c482f6feaeee4915
[4/8] block: fold bio_cur_bytes into blk_rq_cur_bytes
commit: 5eb9cd2ccdf779f83870370c815630a32b7df77d
[5/8] block: move bio_full out of bio.h
commit: 8dc8d6c0124882a931b7f00400c546de36ba888f
[6/8] block: mark __bio_try_merge_page static
commit: 3184916715244d9382c18102e509b995d9ddd2a0
[7/8] block: move bio_get_{first,last}_bvec out of bio.h
commit: ca52cd788dc82151876484255580bbf5e09781ed
[8/8] block: mark bio_truncate static
commit: 55b8648b7650e7b1d2eae81521c642f80f3fd152Best regards,
Signature · 1 line
Jens Axboe