diff options
author | Josef Bacik <josef@toxicpanda.com> | 2022-09-14 11:06:37 -0400 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2022-12-05 18:00:37 +0100 |
commit | 956504a331a613814279b04f9b0d663c7c2bb9bc (patch) | |
tree | 9b55ec7c35796aadb5fc214d8fcad1f1ed28ce0b | |
parent | f60acad355cf14ccccf420e6ea0ddd6de87cb210 (diff) |
btrfs: move trans_handle_cachep out of ctree.h
This is local to the transaction code, remove it from ctree.h and
inode.c, create new helpers in the transaction to handle the init work
and move the cachep locally to transaction.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>
-rw-r--r-- | fs/btrfs/ctree.h | 1 | ||||
-rw-r--r-- | fs/btrfs/inode.c | 8 | ||||
-rw-r--r-- | fs/btrfs/super.c | 9 | ||||
-rw-r--r-- | fs/btrfs/transaction.c | 17 | ||||
-rw-r--r-- | fs/btrfs/transaction.h | 3 |
5 files changed, 28 insertions, 10 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 39974f4b441f..fec3d618bcef 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_trans_handle_cachep; extern struct kmem_cache *btrfs_path_cachep; extern struct kmem_cache *btrfs_free_space_cachep; extern struct kmem_cache *btrfs_free_space_bitmap_cachep; diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 8cae730bd5ba..54f50784aefa 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_trans_handle_cachep; struct kmem_cache *btrfs_path_cachep; struct kmem_cache *btrfs_free_space_cachep; struct kmem_cache *btrfs_free_space_bitmap_cachep; @@ -8926,7 +8925,6 @@ void __cold btrfs_destroy_cachep(void) rcu_barrier(); bioset_exit(&btrfs_dio_bioset); kmem_cache_destroy(btrfs_inode_cachep); - kmem_cache_destroy(btrfs_trans_handle_cachep); kmem_cache_destroy(btrfs_path_cachep); kmem_cache_destroy(btrfs_free_space_cachep); kmem_cache_destroy(btrfs_free_space_bitmap_cachep); @@ -8941,12 +8939,6 @@ int __init btrfs_init_cachep(void) if (!btrfs_inode_cachep) goto fail; - btrfs_trans_handle_cachep = kmem_cache_create("btrfs_trans_handle", - sizeof(struct btrfs_trans_handle), 0, - SLAB_TEMPORARY | SLAB_MEM_SPREAD, NULL); - if (!btrfs_trans_handle_cachep) - goto fail; - btrfs_path_cachep = kmem_cache_create("btrfs_path", sizeof(struct btrfs_path), 0, SLAB_MEM_SPREAD, NULL); diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index 5942b9384088..8fe2fdb167a7 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c @@ -2739,10 +2739,14 @@ static int __init init_btrfs_fs(void) if (err) goto free_compress; - err = extent_state_init_cachep(); + err = btrfs_transaction_init(); if (err) goto free_cachep; + err = extent_state_init_cachep(); + if (err) + goto free_transaction; + err = extent_buffer_init_cachep(); if (err) goto free_extent_cachep; @@ -2811,6 +2815,8 @@ free_eb_cachep: extent_buffer_free_cachep(); free_extent_cachep: extent_state_free_cachep(); +free_transaction: + btrfs_transaction_exit(); free_cachep: btrfs_destroy_cachep(); free_compress: @@ -2822,6 +2828,7 @@ free_compress: static void __exit exit_btrfs_fs(void) { + btrfs_transaction_exit(); btrfs_destroy_cachep(); btrfs_delayed_ref_exit(); btrfs_auto_defrag_exit(); diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c index d1f1da6820fb..ae7d4aca771d 100644 --- a/fs/btrfs/transaction.c +++ b/fs/btrfs/transaction.c @@ -24,6 +24,8 @@ #include "space-info.h" #include "zoned.h" +static struct kmem_cache *btrfs_trans_handle_cachep; + #define BTRFS_ROOT_TRANS_TAG 0 /* @@ -2600,3 +2602,18 @@ void btrfs_apply_pending_changes(struct btrfs_fs_info *fs_info) btrfs_warn(fs_info, "unknown pending changes left 0x%lx, ignoring", prev); } + +int __init btrfs_transaction_init(void) +{ + btrfs_trans_handle_cachep = kmem_cache_create("btrfs_trans_handle", + sizeof(struct btrfs_trans_handle), 0, + SLAB_TEMPORARY | SLAB_MEM_SPREAD, NULL); + if (!btrfs_trans_handle_cachep) + return -ENOMEM; + return 0; +} + +void __cold btrfs_transaction_exit(void) +{ + kmem_cache_destroy(btrfs_trans_handle_cachep); +} diff --git a/fs/btrfs/transaction.h b/fs/btrfs/transaction.h index 970ff316069d..1332f193b800 100644 --- a/fs/btrfs/transaction.h +++ b/fs/btrfs/transaction.h @@ -236,4 +236,7 @@ void btrfs_add_dropped_root(struct btrfs_trans_handle *trans, struct btrfs_root *root); void btrfs_trans_release_chunk_metadata(struct btrfs_trans_handle *trans); +int __init btrfs_transaction_init(void); +void __cold btrfs_transaction_exit(void); + #endif |