diff options
Diffstat (limited to 'fs/bio.c')
-rw-r--r-- | fs/bio.c | 32 |
1 files changed, 21 insertions, 11 deletions
@@ -105,18 +105,22 @@ static inline struct bio_vec *bvec_alloc_bs(unsigned int __nocast gfp_mask, int | |||
105 | return bvl; | 105 | return bvl; |
106 | } | 106 | } |
107 | 107 | ||
108 | /* | 108 | void bio_free(struct bio *bio, struct bio_set *bio_set) |
109 | * default destructor for a bio allocated with bio_alloc_bioset() | ||
110 | */ | ||
111 | static void bio_destructor(struct bio *bio) | ||
112 | { | 109 | { |
113 | const int pool_idx = BIO_POOL_IDX(bio); | 110 | const int pool_idx = BIO_POOL_IDX(bio); |
114 | struct bio_set *bs = bio->bi_set; | ||
115 | 111 | ||
116 | BIO_BUG_ON(pool_idx >= BIOVEC_NR_POOLS); | 112 | BIO_BUG_ON(pool_idx >= BIOVEC_NR_POOLS); |
117 | 113 | ||
118 | mempool_free(bio->bi_io_vec, bs->bvec_pools[pool_idx]); | 114 | mempool_free(bio->bi_io_vec, bio_set->bvec_pools[pool_idx]); |
119 | mempool_free(bio, bs->bio_pool); | 115 | mempool_free(bio, bio_set->bio_pool); |
116 | } | ||
117 | |||
118 | /* | ||
119 | * default destructor for a bio allocated with bio_alloc_bioset() | ||
120 | */ | ||
121 | static void bio_fs_destructor(struct bio *bio) | ||
122 | { | ||
123 | bio_free(bio, fs_bio_set); | ||
120 | } | 124 | } |
121 | 125 | ||
122 | inline void bio_init(struct bio *bio) | 126 | inline void bio_init(struct bio *bio) |
@@ -172,8 +176,6 @@ struct bio *bio_alloc_bioset(unsigned int __nocast gfp_mask, int nr_iovecs, stru | |||
172 | bio->bi_max_vecs = bvec_slabs[idx].nr_vecs; | 176 | bio->bi_max_vecs = bvec_slabs[idx].nr_vecs; |
173 | } | 177 | } |
174 | bio->bi_io_vec = bvl; | 178 | bio->bi_io_vec = bvl; |
175 | bio->bi_destructor = bio_destructor; | ||
176 | bio->bi_set = bs; | ||
177 | } | 179 | } |
178 | out: | 180 | out: |
179 | return bio; | 181 | return bio; |
@@ -181,7 +183,12 @@ out: | |||
181 | 183 | ||
182 | struct bio *bio_alloc(unsigned int __nocast gfp_mask, int nr_iovecs) | 184 | struct bio *bio_alloc(unsigned int __nocast gfp_mask, int nr_iovecs) |
183 | { | 185 | { |
184 | return bio_alloc_bioset(gfp_mask, nr_iovecs, fs_bio_set); | 186 | struct bio *bio = bio_alloc_bioset(gfp_mask, nr_iovecs, fs_bio_set); |
187 | |||
188 | if (bio) | ||
189 | bio->bi_destructor = bio_fs_destructor; | ||
190 | |||
191 | return bio; | ||
185 | } | 192 | } |
186 | 193 | ||
187 | void zero_fill_bio(struct bio *bio) | 194 | void zero_fill_bio(struct bio *bio) |
@@ -274,8 +281,10 @@ struct bio *bio_clone(struct bio *bio, unsigned int __nocast gfp_mask) | |||
274 | { | 281 | { |
275 | struct bio *b = bio_alloc_bioset(gfp_mask, bio->bi_max_vecs, fs_bio_set); | 282 | struct bio *b = bio_alloc_bioset(gfp_mask, bio->bi_max_vecs, fs_bio_set); |
276 | 283 | ||
277 | if (b) | 284 | if (b) { |
285 | b->bi_destructor = bio_fs_destructor; | ||
278 | __bio_clone(b, bio); | 286 | __bio_clone(b, bio); |
287 | } | ||
279 | 288 | ||
280 | return b; | 289 | return b; |
281 | } | 290 | } |
@@ -1211,6 +1220,7 @@ subsys_initcall(init_bio); | |||
1211 | 1220 | ||
1212 | EXPORT_SYMBOL(bio_alloc); | 1221 | EXPORT_SYMBOL(bio_alloc); |
1213 | EXPORT_SYMBOL(bio_put); | 1222 | EXPORT_SYMBOL(bio_put); |
1223 | EXPORT_SYMBOL(bio_free); | ||
1214 | EXPORT_SYMBOL(bio_endio); | 1224 | EXPORT_SYMBOL(bio_endio); |
1215 | EXPORT_SYMBOL(bio_init); | 1225 | EXPORT_SYMBOL(bio_init); |
1216 | EXPORT_SYMBOL(__bio_clone); | 1226 | EXPORT_SYMBOL(__bio_clone); |