Commit 1e2a410f authored by Kent Overstreet's avatar Kent Overstreet Committed by Jens Axboe

block: Ues bi_pool for bio_integrity_alloc()

Now that bios keep track of where they were allocated from,
bio_integrity_alloc_bioset() becomes redundant.

Remove bio_integrity_alloc_bioset() and drop bio_set argument from the
related functions and make them use bio->bi_pool.
Signed-off-by: default avatarKent Overstreet <koverstreet@google.com>
CC: Jens Axboe <axboe@kernel.dk>
CC: Martin K. Petersen <martin.petersen@oracle.com>
Acked-by: default avatarTejun Heo <tj@kernel.org>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 395c72a7
...@@ -2788,7 +2788,7 @@ int blk_rq_prep_clone(struct request *rq, struct request *rq_src, ...@@ -2788,7 +2788,7 @@ int blk_rq_prep_clone(struct request *rq, struct request *rq_src,
__bio_clone(bio, bio_src); __bio_clone(bio, bio_src);
if (bio_integrity(bio_src) && if (bio_integrity(bio_src) &&
bio_integrity_clone(bio, bio_src, gfp_mask, bs)) bio_integrity_clone(bio, bio_src, gfp_mask))
goto free_and_out; goto free_and_out;
if (bio_ctr && bio_ctr(bio, bio_src, data)) if (bio_ctr && bio_ctr(bio, bio_src, data))
......
...@@ -1068,7 +1068,7 @@ static struct bio *split_bvec(struct bio *bio, sector_t sector, ...@@ -1068,7 +1068,7 @@ static struct bio *split_bvec(struct bio *bio, sector_t sector,
clone->bi_flags |= 1 << BIO_CLONED; clone->bi_flags |= 1 << BIO_CLONED;
if (bio_integrity(bio)) { if (bio_integrity(bio)) {
bio_integrity_clone(clone, bio, GFP_NOIO, bs); bio_integrity_clone(clone, bio, GFP_NOIO);
bio_integrity_trim(clone, bio_integrity_trim(clone,
bio_sector_offset(bio, idx, offset), len); bio_sector_offset(bio, idx, offset), len);
} }
...@@ -1094,7 +1094,7 @@ static struct bio *clone_bio(struct bio *bio, sector_t sector, ...@@ -1094,7 +1094,7 @@ static struct bio *clone_bio(struct bio *bio, sector_t sector,
clone->bi_flags &= ~(1 << BIO_SEG_VALID); clone->bi_flags &= ~(1 << BIO_SEG_VALID);
if (bio_integrity(bio)) { if (bio_integrity(bio)) {
bio_integrity_clone(clone, bio, GFP_NOIO, bs); bio_integrity_clone(clone, bio, GFP_NOIO);
if (idx != bio->bi_idx || clone->bi_size < bio->bi_size) if (idx != bio->bi_idx || clone->bi_size < bio->bi_size)
bio_integrity_trim(clone, bio_integrity_trim(clone,
......
...@@ -186,7 +186,7 @@ struct bio *bio_clone_mddev(struct bio *bio, gfp_t gfp_mask, ...@@ -186,7 +186,7 @@ struct bio *bio_clone_mddev(struct bio *bio, gfp_t gfp_mask,
if (bio_integrity(bio)) { if (bio_integrity(bio)) {
int ret; int ret;
ret = bio_integrity_clone(b, bio, gfp_mask, mddev->bio_set); ret = bio_integrity_clone(b, bio, gfp_mask);
if (ret < 0) { if (ret < 0) {
bio_put(b); bio_put(b);
......
...@@ -70,23 +70,25 @@ static inline int use_bip_pool(unsigned int idx) ...@@ -70,23 +70,25 @@ static inline int use_bip_pool(unsigned int idx)
} }
/** /**
* bio_integrity_alloc_bioset - Allocate integrity payload and attach it to bio * bio_integrity_alloc - Allocate integrity payload and attach it to bio
* @bio: bio to attach integrity metadata to * @bio: bio to attach integrity metadata to
* @gfp_mask: Memory allocation mask * @gfp_mask: Memory allocation mask
* @nr_vecs: Number of integrity metadata scatter-gather elements * @nr_vecs: Number of integrity metadata scatter-gather elements
* @bs: bio_set to allocate from
* *
* Description: This function prepares a bio for attaching integrity * Description: This function prepares a bio for attaching integrity
* metadata. nr_vecs specifies the maximum number of pages containing * metadata. nr_vecs specifies the maximum number of pages containing
* integrity metadata that can be attached. * integrity metadata that can be attached.
*/ */
struct bio_integrity_payload *bio_integrity_alloc_bioset(struct bio *bio, struct bio_integrity_payload *bio_integrity_alloc(struct bio *bio,
gfp_t gfp_mask, gfp_t gfp_mask,
unsigned int nr_vecs, unsigned int nr_vecs)
struct bio_set *bs)
{ {
struct bio_integrity_payload *bip; struct bio_integrity_payload *bip;
unsigned int idx = vecs_to_idx(nr_vecs); unsigned int idx = vecs_to_idx(nr_vecs);
struct bio_set *bs = bio->bi_pool;
if (!bs)
bs = fs_bio_set;
BUG_ON(bio == NULL); BUG_ON(bio == NULL);
bip = NULL; bip = NULL;
...@@ -114,37 +116,22 @@ struct bio_integrity_payload *bio_integrity_alloc_bioset(struct bio *bio, ...@@ -114,37 +116,22 @@ struct bio_integrity_payload *bio_integrity_alloc_bioset(struct bio *bio,
return bip; return bip;
} }
EXPORT_SYMBOL(bio_integrity_alloc_bioset);
/**
* bio_integrity_alloc - Allocate integrity payload and attach it to bio
* @bio: bio to attach integrity metadata to
* @gfp_mask: Memory allocation mask
* @nr_vecs: Number of integrity metadata scatter-gather elements
*
* Description: This function prepares a bio for attaching integrity
* metadata. nr_vecs specifies the maximum number of pages containing
* integrity metadata that can be attached.
*/
struct bio_integrity_payload *bio_integrity_alloc(struct bio *bio,
gfp_t gfp_mask,
unsigned int nr_vecs)
{
return bio_integrity_alloc_bioset(bio, gfp_mask, nr_vecs, fs_bio_set);
}
EXPORT_SYMBOL(bio_integrity_alloc); EXPORT_SYMBOL(bio_integrity_alloc);
/** /**
* bio_integrity_free - Free bio integrity payload * bio_integrity_free - Free bio integrity payload
* @bio: bio containing bip to be freed * @bio: bio containing bip to be freed
* @bs: bio_set this bio was allocated from
* *
* Description: Used to free the integrity portion of a bio. Usually * Description: Used to free the integrity portion of a bio. Usually
* called from bio_free(). * called from bio_free().
*/ */
void bio_integrity_free(struct bio *bio, struct bio_set *bs) void bio_integrity_free(struct bio *bio)
{ {
struct bio_integrity_payload *bip = bio->bi_integrity; struct bio_integrity_payload *bip = bio->bi_integrity;
struct bio_set *bs = bio->bi_pool;
if (!bs)
bs = fs_bio_set;
BUG_ON(bip == NULL); BUG_ON(bip == NULL);
...@@ -730,19 +717,18 @@ EXPORT_SYMBOL(bio_integrity_split); ...@@ -730,19 +717,18 @@ EXPORT_SYMBOL(bio_integrity_split);
* @bio: New bio * @bio: New bio
* @bio_src: Original bio * @bio_src: Original bio
* @gfp_mask: Memory allocation mask * @gfp_mask: Memory allocation mask
* @bs: bio_set to allocate bip from
* *
* Description: Called to allocate a bip when cloning a bio * Description: Called to allocate a bip when cloning a bio
*/ */
int bio_integrity_clone(struct bio *bio, struct bio *bio_src, int bio_integrity_clone(struct bio *bio, struct bio *bio_src,
gfp_t gfp_mask, struct bio_set *bs) gfp_t gfp_mask)
{ {
struct bio_integrity_payload *bip_src = bio_src->bi_integrity; struct bio_integrity_payload *bip_src = bio_src->bi_integrity;
struct bio_integrity_payload *bip; struct bio_integrity_payload *bip;
BUG_ON(bip_src == NULL); BUG_ON(bip_src == NULL);
bip = bio_integrity_alloc_bioset(bio, gfp_mask, bip_src->bip_vcnt, bs); bip = bio_integrity_alloc(bio, gfp_mask, bip_src->bip_vcnt);
if (bip == NULL) if (bip == NULL)
return -EIO; return -EIO;
......
...@@ -241,7 +241,7 @@ void bio_free(struct bio *bio, struct bio_set *bs) ...@@ -241,7 +241,7 @@ void bio_free(struct bio *bio, struct bio_set *bs)
bvec_free_bs(bs, bio->bi_io_vec, BIO_POOL_IDX(bio)); bvec_free_bs(bs, bio->bi_io_vec, BIO_POOL_IDX(bio));
if (bio_integrity(bio)) if (bio_integrity(bio))
bio_integrity_free(bio, bs); bio_integrity_free(bio);
/* /*
* If we have front padding, adjust the bio pointer before freeing * If we have front padding, adjust the bio pointer before freeing
...@@ -341,7 +341,7 @@ EXPORT_SYMBOL(bio_alloc); ...@@ -341,7 +341,7 @@ EXPORT_SYMBOL(bio_alloc);
static void bio_kmalloc_destructor(struct bio *bio) static void bio_kmalloc_destructor(struct bio *bio)
{ {
if (bio_integrity(bio)) if (bio_integrity(bio))
bio_integrity_free(bio, fs_bio_set); bio_integrity_free(bio);
kfree(bio); kfree(bio);
} }
...@@ -480,7 +480,7 @@ struct bio *bio_clone(struct bio *bio, gfp_t gfp_mask) ...@@ -480,7 +480,7 @@ struct bio *bio_clone(struct bio *bio, gfp_t gfp_mask)
if (bio_integrity(bio)) { if (bio_integrity(bio)) {
int ret; int ret;
ret = bio_integrity_clone(b, bio, gfp_mask, fs_bio_set); ret = bio_integrity_clone(b, bio, gfp_mask);
if (ret < 0) { if (ret < 0) {
bio_put(b); bio_put(b);
......
...@@ -505,9 +505,8 @@ static inline struct bio *bio_list_get(struct bio_list *bl) ...@@ -505,9 +505,8 @@ static inline struct bio *bio_list_get(struct bio_list *bl)
#define bio_integrity(bio) (bio->bi_integrity != NULL) #define bio_integrity(bio) (bio->bi_integrity != NULL)
extern struct bio_integrity_payload *bio_integrity_alloc_bioset(struct bio *, gfp_t, unsigned int, struct bio_set *);
extern struct bio_integrity_payload *bio_integrity_alloc(struct bio *, gfp_t, unsigned int); extern struct bio_integrity_payload *bio_integrity_alloc(struct bio *, gfp_t, unsigned int);
extern void bio_integrity_free(struct bio *, struct bio_set *); extern void bio_integrity_free(struct bio *);
extern int bio_integrity_add_page(struct bio *, struct page *, unsigned int, unsigned int); extern int bio_integrity_add_page(struct bio *, struct page *, unsigned int, unsigned int);
extern int bio_integrity_enabled(struct bio *bio); extern int bio_integrity_enabled(struct bio *bio);
extern int bio_integrity_set_tag(struct bio *, void *, unsigned int); extern int bio_integrity_set_tag(struct bio *, void *, unsigned int);
...@@ -517,7 +516,7 @@ extern void bio_integrity_endio(struct bio *, int); ...@@ -517,7 +516,7 @@ extern void bio_integrity_endio(struct bio *, int);
extern void bio_integrity_advance(struct bio *, unsigned int); extern void bio_integrity_advance(struct bio *, unsigned int);
extern void bio_integrity_trim(struct bio *, unsigned int, unsigned int); extern void bio_integrity_trim(struct bio *, unsigned int, unsigned int);
extern void bio_integrity_split(struct bio *, struct bio_pair *, int); extern void bio_integrity_split(struct bio *, struct bio_pair *, int);
extern int bio_integrity_clone(struct bio *, struct bio *, gfp_t, struct bio_set *); extern int bio_integrity_clone(struct bio *, struct bio *, gfp_t);
extern int bioset_integrity_create(struct bio_set *, int); extern int bioset_integrity_create(struct bio_set *, int);
extern void bioset_integrity_free(struct bio_set *); extern void bioset_integrity_free(struct bio_set *);
extern void bio_integrity_init(void); extern void bio_integrity_init(void);
...@@ -549,13 +548,13 @@ static inline int bio_integrity_prep(struct bio *bio) ...@@ -549,13 +548,13 @@ static inline int bio_integrity_prep(struct bio *bio)
return 0; return 0;
} }
static inline void bio_integrity_free(struct bio *bio, struct bio_set *bs) static inline void bio_integrity_free(struct bio *bio)
{ {
return; return;
} }
static inline int bio_integrity_clone(struct bio *bio, struct bio *bio_src, static inline int bio_integrity_clone(struct bio *bio, struct bio *bio_src,
gfp_t gfp_mask, struct bio_set *bs) gfp_t gfp_mask)
{ {
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment