diff options
author | Kent Overstreet <koverstreet@google.com> | 2012-09-06 18:35:01 -0400 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2012-09-09 04:35:39 -0400 |
commit | 3f86a82aeb03e6100f7ab39f4702e033a5e38166 (patch) | |
tree | 6d598b5b55c78828f13aee9baffe7350ae18c274 /include/linux/bio.h | |
parent | 4254bba17d92d53822a56ebc2a0c1eb7e2a71155 (diff) |
block: Consolidate bio_alloc_bioset(), bio_kmalloc()
Previously, bio_kmalloc() and bio_alloc_bioset() behaved slightly
different because there was some almost-duplicated code - this fixes
some of that.
The important change is that previously bio_kmalloc() always set
bi_io_vec = bi_inline_vecs, even if nr_iovecs == 0 - unlike
bio_alloc_bioset(). This would cause bio_has_data() to return true; I
don't know if this resulted in any actual bugs but it was certainly
wrong.
bio_kmalloc() and bio_alloc_bioset() also have different arbitrary
limits on nr_iovecs - 1024 (UIO_MAXIOV) for bio_kmalloc(), 256
(BIO_MAX_PAGES) for bio_alloc_bioset(). This patch doesn't fix that, but
at least they're enforced closer together and hopefully they will be
fixed in a later patch.
This'll also help with some future cleanups - there are a fair number of
functions that allocate bios (e.g. bio_clone()), and now they don't have
to be duplicated for bio_alloc(), bio_alloc_bioset(), and bio_kmalloc().
Signed-off-by: Kent Overstreet <koverstreet@google.com>
CC: Jens Axboe <axboe@kernel.dk>
v7: Re-add dropped comments, improv patch description
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'include/linux/bio.h')
-rw-r--r-- | include/linux/bio.h | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/include/linux/bio.h b/include/linux/bio.h index 04944c91fae7..fbe35b175555 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h | |||
@@ -212,11 +212,21 @@ extern void bio_pair_release(struct bio_pair *dbio); | |||
212 | extern struct bio_set *bioset_create(unsigned int, unsigned int); | 212 | extern struct bio_set *bioset_create(unsigned int, unsigned int); |
213 | extern void bioset_free(struct bio_set *); | 213 | extern void bioset_free(struct bio_set *); |
214 | 214 | ||
215 | extern struct bio *bio_alloc(gfp_t, unsigned int); | ||
216 | extern struct bio *bio_kmalloc(gfp_t, unsigned int); | ||
217 | extern struct bio *bio_alloc_bioset(gfp_t, int, struct bio_set *); | 215 | extern struct bio *bio_alloc_bioset(gfp_t, int, struct bio_set *); |
218 | extern void bio_put(struct bio *); | 216 | extern void bio_put(struct bio *); |
219 | 217 | ||
218 | extern struct bio_set *fs_bio_set; | ||
219 | |||
220 | static inline struct bio *bio_alloc(gfp_t gfp_mask, unsigned int nr_iovecs) | ||
221 | { | ||
222 | return bio_alloc_bioset(gfp_mask, nr_iovecs, fs_bio_set); | ||
223 | } | ||
224 | |||
225 | static inline struct bio *bio_kmalloc(gfp_t gfp_mask, unsigned int nr_iovecs) | ||
226 | { | ||
227 | return bio_alloc_bioset(gfp_mask, nr_iovecs, NULL); | ||
228 | } | ||
229 | |||
220 | extern void bio_endio(struct bio *, int); | 230 | extern void bio_endio(struct bio *, int); |
221 | struct request_queue; | 231 | struct request_queue; |
222 | extern int bio_phys_segments(struct request_queue *, struct bio *); | 232 | extern int bio_phys_segments(struct request_queue *, struct bio *); |
@@ -304,8 +314,6 @@ struct biovec_slab { | |||
304 | struct kmem_cache *slab; | 314 | struct kmem_cache *slab; |
305 | }; | 315 | }; |
306 | 316 | ||
307 | extern struct bio_set *fs_bio_set; | ||
308 | |||
309 | /* | 317 | /* |
310 | * a small number of entries is fine, not going to be performance critical. | 318 | * a small number of entries is fine, not going to be performance critical. |
311 | * basically we just need to survive | 319 | * basically we just need to survive |