Commit 8ac9f7c1 authored by Kent Overstreet's avatar Kent Overstreet Committed by Jens Axboe

btrfs: convert to bioset_init()/mempool_init()

Convert btrfs to embedded bio sets.
Acked-by: default avatarChris Mason <clm@fb.com>
Signed-off-by: default avatarKent Overstreet <kent.overstreet@gmail.com>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 52190f8a
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
static struct kmem_cache *extent_state_cache; static struct kmem_cache *extent_state_cache;
static struct kmem_cache *extent_buffer_cache; static struct kmem_cache *extent_buffer_cache;
static struct bio_set *btrfs_bioset; static struct bio_set btrfs_bioset;
static inline bool extent_state_in_tree(const struct extent_state *state) static inline bool extent_state_in_tree(const struct extent_state *state)
{ {
...@@ -162,20 +162,18 @@ int __init extent_io_init(void) ...@@ -162,20 +162,18 @@ int __init extent_io_init(void)
if (!extent_buffer_cache) if (!extent_buffer_cache)
goto free_state_cache; goto free_state_cache;
btrfs_bioset = bioset_create(BIO_POOL_SIZE, if (bioset_init(&btrfs_bioset, BIO_POOL_SIZE,
offsetof(struct btrfs_io_bio, bio), offsetof(struct btrfs_io_bio, bio),
BIOSET_NEED_BVECS); BIOSET_NEED_BVECS))
if (!btrfs_bioset)
goto free_buffer_cache; goto free_buffer_cache;
if (bioset_integrity_create(btrfs_bioset, BIO_POOL_SIZE)) if (bioset_integrity_create(&btrfs_bioset, BIO_POOL_SIZE))
goto free_bioset; goto free_bioset;
return 0; return 0;
free_bioset: free_bioset:
bioset_free(btrfs_bioset); bioset_exit(&btrfs_bioset);
btrfs_bioset = NULL;
free_buffer_cache: free_buffer_cache:
kmem_cache_destroy(extent_buffer_cache); kmem_cache_destroy(extent_buffer_cache);
...@@ -198,8 +196,7 @@ void __cold extent_io_exit(void) ...@@ -198,8 +196,7 @@ void __cold extent_io_exit(void)
rcu_barrier(); rcu_barrier();
kmem_cache_destroy(extent_state_cache); kmem_cache_destroy(extent_state_cache);
kmem_cache_destroy(extent_buffer_cache); kmem_cache_destroy(extent_buffer_cache);
if (btrfs_bioset) bioset_exit(&btrfs_bioset);
bioset_free(btrfs_bioset);
} }
void extent_io_tree_init(struct extent_io_tree *tree, void extent_io_tree_init(struct extent_io_tree *tree,
...@@ -2679,7 +2676,7 @@ struct bio *btrfs_bio_alloc(struct block_device *bdev, u64 first_byte) ...@@ -2679,7 +2676,7 @@ struct bio *btrfs_bio_alloc(struct block_device *bdev, u64 first_byte)
{ {
struct bio *bio; struct bio *bio;
bio = bio_alloc_bioset(GFP_NOFS, BIO_MAX_PAGES, btrfs_bioset); bio = bio_alloc_bioset(GFP_NOFS, BIO_MAX_PAGES, &btrfs_bioset);
bio_set_dev(bio, bdev); bio_set_dev(bio, bdev);
bio->bi_iter.bi_sector = first_byte >> 9; bio->bi_iter.bi_sector = first_byte >> 9;
btrfs_io_bio_init(btrfs_io_bio(bio)); btrfs_io_bio_init(btrfs_io_bio(bio));
...@@ -2692,7 +2689,7 @@ struct bio *btrfs_bio_clone(struct bio *bio) ...@@ -2692,7 +2689,7 @@ struct bio *btrfs_bio_clone(struct bio *bio)
struct bio *new; struct bio *new;
/* Bio allocation backed by a bioset does not fail */ /* Bio allocation backed by a bioset does not fail */
new = bio_clone_fast(bio, GFP_NOFS, btrfs_bioset); new = bio_clone_fast(bio, GFP_NOFS, &btrfs_bioset);
btrfs_bio = btrfs_io_bio(new); btrfs_bio = btrfs_io_bio(new);
btrfs_io_bio_init(btrfs_bio); btrfs_io_bio_init(btrfs_bio);
btrfs_bio->iter = bio->bi_iter; btrfs_bio->iter = bio->bi_iter;
...@@ -2704,7 +2701,7 @@ struct bio *btrfs_io_bio_alloc(unsigned int nr_iovecs) ...@@ -2704,7 +2701,7 @@ struct bio *btrfs_io_bio_alloc(unsigned int nr_iovecs)
struct bio *bio; struct bio *bio;
/* Bio allocation backed by a bioset does not fail */ /* Bio allocation backed by a bioset does not fail */
bio = bio_alloc_bioset(GFP_NOFS, nr_iovecs, btrfs_bioset); bio = bio_alloc_bioset(GFP_NOFS, nr_iovecs, &btrfs_bioset);
btrfs_io_bio_init(btrfs_io_bio(bio)); btrfs_io_bio_init(btrfs_io_bio(bio));
return bio; return bio;
} }
...@@ -2715,7 +2712,7 @@ struct bio *btrfs_bio_clone_partial(struct bio *orig, int offset, int size) ...@@ -2715,7 +2712,7 @@ struct bio *btrfs_bio_clone_partial(struct bio *orig, int offset, int size)
struct btrfs_io_bio *btrfs_bio; struct btrfs_io_bio *btrfs_bio;
/* this will never fail when it's backed by a bioset */ /* this will never fail when it's backed by a bioset */
bio = bio_clone_fast(orig, GFP_NOFS, btrfs_bioset); bio = bio_clone_fast(orig, GFP_NOFS, &btrfs_bioset);
ASSERT(bio); ASSERT(bio);
btrfs_bio = btrfs_io_bio(bio); btrfs_bio = btrfs_io_bio(bio);
......
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