diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2020-05-25 20:35:53 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 17:08:40 -0400 |
commit | c823c3390bd2f325f78bab493f84ea8a84f5ddc2 (patch) | |
tree | 63d99f308c88f24986136c9f3991e0bb6cdaf170 /fs | |
parent | 96e2aa1be5eebd81ed572baf69f8cb82d56e39bd (diff) | |
download | linux-c823c3390bd2f325f78bab493f84ea8a84f5ddc2.tar.gz linux-c823c3390bd2f325f78bab493f84ea8a84f5ddc2.tar.bz2 linux-c823c3390bd2f325f78bab493f84ea8a84f5ddc2.zip |
bcachefs: Factor out bch2_fs_btree_interior_update_init()
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/bcachefs/btree_update_interior.c | 19 | ||||
-rw-r--r-- | fs/bcachefs/btree_update_interior.h | 3 | ||||
-rw-r--r-- | fs/bcachefs/super.c | 13 |
3 files changed, 24 insertions, 11 deletions
diff --git a/fs/bcachefs/btree_update_interior.c b/fs/bcachefs/btree_update_interior.c index 28568db5834a..1867d732afd4 100644 --- a/fs/bcachefs/btree_update_interior.c +++ b/fs/bcachefs/btree_update_interior.c @@ -2247,3 +2247,22 @@ size_t bch2_btree_interior_updates_nr_pending(struct bch_fs *c) return ret; } + +void bch2_fs_btree_interior_update_exit(struct bch_fs *c) +{ + mempool_exit(&c->btree_interior_update_pool); + mempool_exit(&c->btree_reserve_pool); +} + +int bch2_fs_btree_interior_update_init(struct bch_fs *c) +{ + mutex_init(&c->btree_reserve_cache_lock); + INIT_LIST_HEAD(&c->btree_interior_update_list); + INIT_LIST_HEAD(&c->btree_interior_updates_unwritten); + mutex_init(&c->btree_interior_update_lock); + + return mempool_init_kmalloc_pool(&c->btree_reserve_pool, 1, + sizeof(struct btree_reserve)) ?: + mempool_init_kmalloc_pool(&c->btree_interior_update_pool, 1, + sizeof(struct btree_update)); +} diff --git a/fs/bcachefs/btree_update_interior.h b/fs/bcachefs/btree_update_interior.h index fb35be00f1bb..5cec87951dc7 100644 --- a/fs/bcachefs/btree_update_interior.h +++ b/fs/bcachefs/btree_update_interior.h @@ -333,4 +333,7 @@ ssize_t bch2_btree_updates_print(struct bch_fs *, char *); size_t bch2_btree_interior_updates_nr_pending(struct bch_fs *); +void bch2_fs_btree_interior_update_exit(struct bch_fs *); +int bch2_fs_btree_interior_update_init(struct bch_fs *); + #endif /* _BCACHEFS_BTREE_UPDATE_INTERIOR_H */ diff --git a/fs/bcachefs/super.c b/fs/bcachefs/super.c index 165163f3896e..4335e0a11c2e 100644 --- a/fs/bcachefs/super.c +++ b/fs/bcachefs/super.c @@ -476,6 +476,7 @@ static void bch2_fs_free(struct bch_fs *c) bch2_fs_ec_exit(c); bch2_fs_encryption_exit(c); bch2_fs_io_exit(c); + bch2_fs_btree_interior_update_exit(c); bch2_fs_btree_iter_exit(c); bch2_fs_btree_cache_exit(c); bch2_fs_journal_exit(&c->journal); @@ -494,8 +495,6 @@ static void bch2_fs_free(struct bch_fs *c) mempool_exit(&c->large_bkey_pool); mempool_exit(&c->btree_bounce_pool); bioset_exit(&c->btree_bio); - mempool_exit(&c->btree_interior_update_pool); - mempool_exit(&c->btree_reserve_pool); mempool_exit(&c->fill_iter); percpu_ref_exit(&c->writes); kfree(c->replicas.entries); @@ -657,11 +656,6 @@ static struct bch_fs *bch2_fs_alloc(struct bch_sb *sb, struct bch_opts opts) INIT_LIST_HEAD(&c->list); - INIT_LIST_HEAD(&c->btree_interior_update_list); - INIT_LIST_HEAD(&c->btree_interior_updates_unwritten); - mutex_init(&c->btree_reserve_cache_lock); - mutex_init(&c->btree_interior_update_lock); - mutex_init(&c->usage_scratch_lock); mutex_init(&c->bio_bounce_pages_lock); @@ -736,10 +730,6 @@ static struct bch_fs *bch2_fs_alloc(struct bch_sb *sb, struct bch_opts opts) WQ_FREEZABLE|WQ_MEM_RECLAIM|WQ_HIGHPRI, 1)) || percpu_ref_init(&c->writes, bch2_writes_disabled, PERCPU_REF_INIT_DEAD, GFP_KERNEL) || - mempool_init_kmalloc_pool(&c->btree_reserve_pool, 1, - sizeof(struct btree_reserve)) || - mempool_init_kmalloc_pool(&c->btree_interior_update_pool, 1, - sizeof(struct btree_update)) || mempool_init_kmalloc_pool(&c->fill_iter, 1, iter_size) || bioset_init(&c->btree_bio, 1, max(offsetof(struct btree_read_bio, bio), @@ -756,6 +746,7 @@ static struct bch_fs *bch2_fs_alloc(struct bch_sb *sb, struct bch_opts opts) bch2_fs_replicas_init(c) || bch2_fs_btree_cache_init(c) || bch2_fs_btree_iter_init(c) || + bch2_fs_btree_interior_update_init(c) || bch2_fs_io_init(c) || bch2_fs_encryption_init(c) || bch2_fs_compress_init(c) || |