diff options
author | Josef Bacik <josef@toxicpanda.com> | 2022-09-14 18:06:38 +0300 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2022-12-05 20:00:37 +0300 |
commit | 226463d7b100d30def24f2be492fef0081003a30 (patch) | |
tree | dfb642dc9bc836aae13093584a52f6691e423e5a /fs | |
parent | 956504a331a613814279b04f9b0d663c7c2bb9bc (diff) | |
download | linux-226463d7b100d30def24f2be492fef0081003a30.tar.xz |
btrfs: move btrfs_path_cachep out of ctree.h
This is local to the ctree code, remove it from ctree.h and inode.c,
create new init/exit functions for the cachep, and move it locally to
ctree.c.
Reviewed-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/btrfs/ctree.c | 17 | ||||
-rw-r--r-- | fs/btrfs/ctree.h | 3 | ||||
-rw-r--r-- | fs/btrfs/inode.c | 8 | ||||
-rw-r--r-- | fs/btrfs/super.c | 9 |
4 files changed, 27 insertions, 10 deletions
diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c index dcb510f38dda..4f2d367e1207 100644 --- a/fs/btrfs/ctree.c +++ b/fs/btrfs/ctree.c @@ -18,6 +18,8 @@ #include "tree-mod-log.h" #include "tree-checker.h" +static struct kmem_cache *btrfs_path_cachep; + static int split_node(struct btrfs_trans_handle *trans, struct btrfs_root *root, struct btrfs_path *path, int level); static int split_leaf(struct btrfs_trans_handle *trans, struct btrfs_root *root, @@ -4933,3 +4935,18 @@ int btrfs_previous_extent_item(struct btrfs_root *root, } return 1; } + +int __init btrfs_ctree_init(void) +{ + btrfs_path_cachep = kmem_cache_create("btrfs_path", + sizeof(struct btrfs_path), 0, + SLAB_MEM_SPREAD, NULL); + if (!btrfs_path_cachep) + return -ENOMEM; + return 0; +} + +void __cold btrfs_ctree_exit(void) +{ + kmem_cache_destroy(btrfs_path_cachep); +} diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index fec3d618bcef..282571b54b6d 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -41,7 +41,6 @@ struct btrfs_pending_snapshot; struct btrfs_delayed_ref_root; struct btrfs_space_info; struct btrfs_block_group; -extern struct kmem_cache *btrfs_path_cachep; extern struct kmem_cache *btrfs_free_space_cachep; extern struct kmem_cache *btrfs_free_space_bitmap_cachep; struct btrfs_ordered_sum; @@ -2662,6 +2661,8 @@ void btrfs_end_write_no_snapshotting(struct btrfs_root *root); void btrfs_wait_for_snapshot_creation(struct btrfs_root *root); /* ctree.c */ +int __init btrfs_ctree_init(void); +void __cold btrfs_ctree_exit(void); int btrfs_bin_search(struct extent_buffer *eb, const struct btrfs_key *key, int *slot); int __pure btrfs_comp_cpu_keys(const struct btrfs_key *k1, const struct btrfs_key *k2); diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 54f50784aefa..39c474e8a312 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -107,7 +107,6 @@ static const struct address_space_operations btrfs_aops; static const struct file_operations btrfs_dir_file_operations; static struct kmem_cache *btrfs_inode_cachep; -struct kmem_cache *btrfs_path_cachep; struct kmem_cache *btrfs_free_space_cachep; struct kmem_cache *btrfs_free_space_bitmap_cachep; @@ -8925,7 +8924,6 @@ void __cold btrfs_destroy_cachep(void) rcu_barrier(); bioset_exit(&btrfs_dio_bioset); kmem_cache_destroy(btrfs_inode_cachep); - kmem_cache_destroy(btrfs_path_cachep); kmem_cache_destroy(btrfs_free_space_cachep); kmem_cache_destroy(btrfs_free_space_bitmap_cachep); } @@ -8939,12 +8937,6 @@ int __init btrfs_init_cachep(void) if (!btrfs_inode_cachep) goto fail; - btrfs_path_cachep = kmem_cache_create("btrfs_path", - sizeof(struct btrfs_path), 0, - SLAB_MEM_SPREAD, NULL); - if (!btrfs_path_cachep) - goto fail; - btrfs_free_space_cachep = kmem_cache_create("btrfs_free_space", sizeof(struct btrfs_free_space), 0, SLAB_MEM_SPREAD, NULL); diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index 8fe2fdb167a7..9f8b77553de0 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c @@ -2743,10 +2743,14 @@ static int __init init_btrfs_fs(void) if (err) goto free_cachep; - err = extent_state_init_cachep(); + err = btrfs_ctree_init(); if (err) goto free_transaction; + err = extent_state_init_cachep(); + if (err) + goto free_ctree; + err = extent_buffer_init_cachep(); if (err) goto free_extent_cachep; @@ -2815,6 +2819,8 @@ free_eb_cachep: extent_buffer_free_cachep(); free_extent_cachep: extent_state_free_cachep(); +free_ctree: + btrfs_ctree_exit(); free_transaction: btrfs_transaction_exit(); free_cachep: @@ -2828,6 +2834,7 @@ free_compress: static void __exit exit_btrfs_fs(void) { + btrfs_ctree_exit(); btrfs_transaction_exit(); btrfs_destroy_cachep(); btrfs_delayed_ref_exit(); |