Skip to content

Commit

Permalink
btrfs: convert to bioset_init()/mempool_init()
Browse files Browse the repository at this point in the history
Convert btrfs to embedded bio sets.

Acked-by: Chris Mason <[email protected]>
Signed-off-by: Kent Overstreet <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
koverstreet authored and axboe committed May 30, 2018
1 parent 52190f8 commit 8ac9f7c
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions fs/btrfs/extent_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

static struct kmem_cache *extent_state_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)
{
Expand Down Expand Up @@ -162,20 +162,18 @@ int __init extent_io_init(void)
if (!extent_buffer_cache)
goto free_state_cache;

btrfs_bioset = bioset_create(BIO_POOL_SIZE,
offsetof(struct btrfs_io_bio, bio),
BIOSET_NEED_BVECS);
if (!btrfs_bioset)
if (bioset_init(&btrfs_bioset, BIO_POOL_SIZE,
offsetof(struct btrfs_io_bio, bio),
BIOSET_NEED_BVECS))
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;

return 0;

free_bioset:
bioset_free(btrfs_bioset);
btrfs_bioset = NULL;
bioset_exit(&btrfs_bioset);

free_buffer_cache:
kmem_cache_destroy(extent_buffer_cache);
Expand All @@ -198,8 +196,7 @@ void __cold extent_io_exit(void)
rcu_barrier();
kmem_cache_destroy(extent_state_cache);
kmem_cache_destroy(extent_buffer_cache);
if (btrfs_bioset)
bioset_free(btrfs_bioset);
bioset_exit(&btrfs_bioset);
}

void extent_io_tree_init(struct extent_io_tree *tree,
Expand Down Expand Up @@ -2679,7 +2676,7 @@ struct bio *btrfs_bio_alloc(struct block_device *bdev, u64 first_byte)
{
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->bi_iter.bi_sector = first_byte >> 9;
btrfs_io_bio_init(btrfs_io_bio(bio));
Expand All @@ -2692,7 +2689,7 @@ struct bio *btrfs_bio_clone(struct bio *bio)
struct bio *new;

/* 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_io_bio_init(btrfs_bio);
btrfs_bio->iter = bio->bi_iter;
Expand All @@ -2704,7 +2701,7 @@ struct bio *btrfs_io_bio_alloc(unsigned int nr_iovecs)
struct bio *bio;

/* 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));
return bio;
}
Expand All @@ -2715,7 +2712,7 @@ struct bio *btrfs_bio_clone_partial(struct bio *orig, int offset, int size)
struct btrfs_io_bio *btrfs_bio;

/* 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);

btrfs_bio = btrfs_io_bio(bio);
Expand Down

0 comments on commit 8ac9f7c

Please sign in to comment.