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>
This commit is contained in:
Josef Bacik 2022-09-14 11:06:38 -04:00 committed by David Sterba
parent 956504a331
commit 226463d7b1
4 changed files with 27 additions and 10 deletions

View File

@ -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);
}

View File

@ -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);

View File

@ -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);

View File

@ -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();