aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKent Overstreet <koverstreet@google.com>2012-09-06 18:34:56 -0400
committerJens Axboe <axboe@kernel.dk>2012-09-09 04:35:38 -0400
commit1e2a410ff71504a64d1af2e354287ac51aeac1b0 (patch)
treee4ae4669d958fc932e5ae67cafd8de860f1f91c9
parent395c72a707d966b36d5a42fe12c3a237ded3a0d9 (diff)
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: Kent Overstreet <koverstreet@google.com> CC: Jens Axboe <axboe@kernel.dk> CC: Martin K. Petersen <martin.petersen@oracle.com> Acked-by: Tejun Heo <tj@kernel.org> Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r--block/blk-core.c2
-rw-r--r--drivers/md/dm.c4
-rw-r--r--drivers/md/md.c2
-rw-r--r--fs/bio-integrity.c44
-rw-r--r--fs/bio.c6
-rw-r--r--include/linux/bio.h9
6 files changed, 26 insertions, 41 deletions
diff --git a/block/blk-core.c b/block/blk-core.c
index 4b4dbdfbca89..95c493511be7 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -2788,7 +2788,7 @@ int blk_rq_prep_clone(struct request *rq, struct request *rq_src,
2788 __bio_clone(bio, bio_src); 2788 __bio_clone(bio, bio_src);
2789 2789
2790 if (bio_integrity(bio_src) && 2790 if (bio_integrity(bio_src) &&
2791 bio_integrity_clone(bio, bio_src, gfp_mask, bs)) 2791 bio_integrity_clone(bio, bio_src, gfp_mask))
2792 goto free_and_out; 2792 goto free_and_out;
2793 2793
2794 if (bio_ctr && bio_ctr(bio, bio_src, data)) 2794 if (bio_ctr && bio_ctr(bio, bio_src, data))
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index 0c3d6dd51897..f43aaf689bd0 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -1068,7 +1068,7 @@ static struct bio *split_bvec(struct bio *bio, sector_t sector,
1068 clone->bi_flags |= 1 << BIO_CLONED; 1068 clone->bi_flags |= 1 << BIO_CLONED;
1069 1069
1070 if (bio_integrity(bio)) { 1070 if (bio_integrity(bio)) {
1071 bio_integrity_clone(clone, bio, GFP_NOIO, bs); 1071 bio_integrity_clone(clone, bio, GFP_NOIO);
1072 bio_integrity_trim(clone, 1072 bio_integrity_trim(clone,
1073 bio_sector_offset(bio, idx, offset), len); 1073 bio_sector_offset(bio, idx, offset), len);
1074 } 1074 }
@@ -1094,7 +1094,7 @@ static struct bio *clone_bio(struct bio *bio, sector_t sector,
1094 clone->bi_flags &= ~(1 << BIO_SEG_VALID); 1094 clone->bi_flags &= ~(1 << BIO_SEG_VALID);
1095 1095
1096 if (bio_integrity(bio)) { 1096 if (bio_integrity(bio)) {
1097 bio_integrity_clone(clone, bio, GFP_NOIO, bs); 1097 bio_integrity_clone(clone, bio, GFP_NOIO);
1098 1098
1099 if (idx != bio->bi_idx || clone->bi_size < bio->bi_size) 1099 if (idx != bio->bi_idx || clone->bi_size < bio->bi_size)
1100 bio_integrity_trim(clone, 1100 bio_integrity_trim(clone,
diff --git a/drivers/md/md.c b/drivers/md/md.c
index b8eebe357b2b..457ca8451ddb 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -186,7 +186,7 @@ struct bio *bio_clone_mddev(struct bio *bio, gfp_t gfp_mask,
186 if (bio_integrity(bio)) { 186 if (bio_integrity(bio)) {
187 int ret; 187 int ret;
188 188
189 ret = bio_integrity_clone(b, bio, gfp_mask, mddev->bio_set); 189 ret = bio_integrity_clone(b, bio, gfp_mask);
190 190
191 if (ret < 0) { 191 if (ret < 0) {
192 bio_put(b); 192 bio_put(b);
diff --git a/fs/bio-integrity.c b/fs/bio-integrity.c
index e85c04b9f61c..a3f28f331b2b 100644
--- a/fs/bio-integrity.c
+++ b/fs/bio-integrity.c
@@ -70,23 +70,25 @@ static inline int use_bip_pool(unsigned int idx)
70} 70}
71 71
72/** 72/**
73 * bio_integrity_alloc_bioset - Allocate integrity payload and attach it to bio 73 * bio_integrity_alloc - Allocate integrity payload and attach it to bio
74 * @bio: bio to attach integrity metadata to 74 * @bio: bio to attach integrity metadata to
75 * @gfp_mask: Memory allocation mask 75 * @gfp_mask: Memory allocation mask
76 * @nr_vecs: Number of integrity metadata scatter-gather elements 76 * @nr_vecs: Number of integrity metadata scatter-gather elements
77 * @bs: bio_set to allocate from
78 * 77 *
79 * Description: This function prepares a bio for attaching integrity 78 * Description: This function prepares a bio for attaching integrity
80 * metadata. nr_vecs specifies the maximum number of pages containing 79 * metadata. nr_vecs specifies the maximum number of pages containing
81 * integrity metadata that can be attached. 80 * integrity metadata that can be attached.
82 */ 81 */
83struct bio_integrity_payload *bio_integrity_alloc_bioset(struct bio *bio, 82struct bio_integrity_payload *bio_integrity_alloc(struct bio *bio,
84 gfp_t gfp_mask, 83 gfp_t gfp_mask,
85 unsigned int nr_vecs, 84 unsigned int nr_vecs)
86 struct bio_set *bs)
87{ 85{
88 struct bio_integrity_payload *bip; 86 struct bio_integrity_payload *bip;
89 unsigned int idx = vecs_to_idx(nr_vecs); 87 unsigned int idx = vecs_to_idx(nr_vecs);
88 struct bio_set *bs = bio->bi_pool;
89
90 if (!bs)
91 bs = fs_bio_set;
90 92
91 BUG_ON(bio == NULL); 93 BUG_ON(bio == NULL);
92 bip = NULL; 94 bip = NULL;
@@ -114,37 +116,22 @@ struct bio_integrity_payload *bio_integrity_alloc_bioset(struct bio *bio,
114 116
115 return bip; 117 return bip;
116} 118}
117EXPORT_SYMBOL(bio_integrity_alloc_bioset);
118
119/**
120 * bio_integrity_alloc - Allocate integrity payload and attach it to bio
121 * @bio: bio to attach integrity metadata to
122 * @gfp_mask: Memory allocation mask
123 * @nr_vecs: Number of integrity metadata scatter-gather elements
124 *
125 * Description: This function prepares a bio for attaching integrity
126 * metadata. nr_vecs specifies the maximum number of pages containing
127 * integrity metadata that can be attached.
128 */
129struct bio_integrity_payload *bio_integrity_alloc(struct bio *bio,
130 gfp_t gfp_mask,
131 unsigned int nr_vecs)
132{
133 return bio_integrity_alloc_bioset(bio, gfp_mask, nr_vecs, fs_bio_set);
134}
135EXPORT_SYMBOL(bio_integrity_alloc); 119EXPORT_SYMBOL(bio_integrity_alloc);
136 120
137/** 121/**
138 * bio_integrity_free - Free bio integrity payload 122 * bio_integrity_free - Free bio integrity payload
139 * @bio: bio containing bip to be freed 123 * @bio: bio containing bip to be freed
140 * @bs: bio_set this bio was allocated from
141 * 124 *
142 * Description: Used to free the integrity portion of a bio. Usually 125 * Description: Used to free the integrity portion of a bio. Usually
143 * called from bio_free(). 126 * called from bio_free().
144 */ 127 */
145void bio_integrity_free(struct bio *bio, struct bio_set *bs) 128void bio_integrity_free(struct bio *bio)
146{ 129{
147 struct bio_integrity_payload *bip = bio->bi_integrity; 130 struct bio_integrity_payload *bip = bio->bi_integrity;
131 struct bio_set *bs = bio->bi_pool;
132
133 if (!bs)
134 bs = fs_bio_set;
148 135
149 BUG_ON(bip == NULL); 136 BUG_ON(bip == NULL);
150 137
@@ -730,19 +717,18 @@ EXPORT_SYMBOL(bio_integrity_split);
730 * @bio: New bio 717 * @bio: New bio
731 * @bio_src: Original bio 718 * @bio_src: Original bio
732 * @gfp_mask: Memory allocation mask 719 * @gfp_mask: Memory allocation mask
733 * @bs: bio_set to allocate bip from
734 * 720 *
735 * Description: Called to allocate a bip when cloning a bio 721 * Description: Called to allocate a bip when cloning a bio
736 */ 722 */
737int bio_integrity_clone(struct bio *bio, struct bio *bio_src, 723int bio_integrity_clone(struct bio *bio, struct bio *bio_src,
738 gfp_t gfp_mask, struct bio_set *bs) 724 gfp_t gfp_mask)
739{ 725{
740 struct bio_integrity_payload *bip_src = bio_src->bi_integrity; 726 struct bio_integrity_payload *bip_src = bio_src->bi_integrity;
741 struct bio_integrity_payload *bip; 727 struct bio_integrity_payload *bip;
742 728
743 BUG_ON(bip_src == NULL); 729 BUG_ON(bip_src == NULL);
744 730
745 bip = bio_integrity_alloc_bioset(bio, gfp_mask, bip_src->bip_vcnt, bs); 731 bip = bio_integrity_alloc(bio, gfp_mask, bip_src->bip_vcnt);
746 732
747 if (bip == NULL) 733 if (bip == NULL)
748 return -EIO; 734 return -EIO;
diff --git a/fs/bio.c b/fs/bio.c
index e017f7a5cdc6..b14f71adff4a 100644
--- a/fs/bio.c
+++ b/fs/bio.c
@@ -241,7 +241,7 @@ void bio_free(struct bio *bio, struct bio_set *bs)
241 bvec_free_bs(bs, bio->bi_io_vec, BIO_POOL_IDX(bio)); 241 bvec_free_bs(bs, bio->bi_io_vec, BIO_POOL_IDX(bio));
242 242
243 if (bio_integrity(bio)) 243 if (bio_integrity(bio))
244 bio_integrity_free(bio, bs); 244 bio_integrity_free(bio);
245 245
246 /* 246 /*
247 * If we have front padding, adjust the bio pointer before freeing 247 * If we have front padding, adjust the bio pointer before freeing
@@ -341,7 +341,7 @@ EXPORT_SYMBOL(bio_alloc);
341static void bio_kmalloc_destructor(struct bio *bio) 341static void bio_kmalloc_destructor(struct bio *bio)
342{ 342{
343 if (bio_integrity(bio)) 343 if (bio_integrity(bio))
344 bio_integrity_free(bio, fs_bio_set); 344 bio_integrity_free(bio);
345 kfree(bio); 345 kfree(bio);
346} 346}
347 347
@@ -480,7 +480,7 @@ struct bio *bio_clone(struct bio *bio, gfp_t gfp_mask)
480 if (bio_integrity(bio)) { 480 if (bio_integrity(bio)) {
481 int ret; 481 int ret;
482 482
483 ret = bio_integrity_clone(b, bio, gfp_mask, fs_bio_set); 483 ret = bio_integrity_clone(b, bio, gfp_mask);
484 484
485 if (ret < 0) { 485 if (ret < 0) {
486 bio_put(b); 486 bio_put(b);
diff --git a/include/linux/bio.h b/include/linux/bio.h
index 26435890dc87..a11f74bc82d2 100644
--- a/include/linux/bio.h
+++ b/include/linux/bio.h
@@ -505,9 +505,8 @@ static inline struct bio *bio_list_get(struct bio_list *bl)
505 505
506#define bio_integrity(bio) (bio->bi_integrity != NULL) 506#define bio_integrity(bio) (bio->bi_integrity != NULL)
507 507
508extern struct bio_integrity_payload *bio_integrity_alloc_bioset(struct bio *, gfp_t, unsigned int, struct bio_set *);
509extern struct bio_integrity_payload *bio_integrity_alloc(struct bio *, gfp_t, unsigned int); 508extern struct bio_integrity_payload *bio_integrity_alloc(struct bio *, gfp_t, unsigned int);
510extern void bio_integrity_free(struct bio *, struct bio_set *); 509extern void bio_integrity_free(struct bio *);
511extern int bio_integrity_add_page(struct bio *, struct page *, unsigned int, unsigned int); 510extern int bio_integrity_add_page(struct bio *, struct page *, unsigned int, unsigned int);
512extern int bio_integrity_enabled(struct bio *bio); 511extern int bio_integrity_enabled(struct bio *bio);
513extern int bio_integrity_set_tag(struct bio *, void *, unsigned int); 512extern int bio_integrity_set_tag(struct bio *, void *, unsigned int);
@@ -517,7 +516,7 @@ extern void bio_integrity_endio(struct bio *, int);
517extern void bio_integrity_advance(struct bio *, unsigned int); 516extern void bio_integrity_advance(struct bio *, unsigned int);
518extern void bio_integrity_trim(struct bio *, unsigned int, unsigned int); 517extern void bio_integrity_trim(struct bio *, unsigned int, unsigned int);
519extern void bio_integrity_split(struct bio *, struct bio_pair *, int); 518extern void bio_integrity_split(struct bio *, struct bio_pair *, int);
520extern int bio_integrity_clone(struct bio *, struct bio *, gfp_t, struct bio_set *); 519extern int bio_integrity_clone(struct bio *, struct bio *, gfp_t);
521extern int bioset_integrity_create(struct bio_set *, int); 520extern int bioset_integrity_create(struct bio_set *, int);
522extern void bioset_integrity_free(struct bio_set *); 521extern void bioset_integrity_free(struct bio_set *);
523extern void bio_integrity_init(void); 522extern void bio_integrity_init(void);
@@ -549,13 +548,13 @@ static inline int bio_integrity_prep(struct bio *bio)
549 return 0; 548 return 0;
550} 549}
551 550
552static inline void bio_integrity_free(struct bio *bio, struct bio_set *bs) 551static inline void bio_integrity_free(struct bio *bio)
553{ 552{
554 return; 553 return;
555} 554}
556 555
557static inline int bio_integrity_clone(struct bio *bio, struct bio *bio_src, 556static inline int bio_integrity_clone(struct bio *bio, struct bio *bio_src,
558 gfp_t gfp_mask, struct bio_set *bs) 557 gfp_t gfp_mask)
559{ 558{
560 return 0; 559 return 0;
561} 560}