Commit d0022290 authored by Kent Overstreet's avatar Kent Overstreet Committed by Kent Overstreet

bcachefs: Fix error in filesystem initialization

The rhashtable code doesn't like when we destroy an rhashtable that was
never initialized
Signed-off-by: default avatarKent Overstreet <kent.overstreet@gmail.com>
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 5731cf01
...@@ -608,7 +608,8 @@ void bch2_fs_btree_key_cache_exit(struct btree_key_cache *bc) ...@@ -608,7 +608,8 @@ void bch2_fs_btree_key_cache_exit(struct btree_key_cache *bc)
} }
mutex_unlock(&bc->lock); mutex_unlock(&bc->lock);
rhashtable_destroy(&bc->table); if (bc->table_init_done)
rhashtable_destroy(&bc->table);
} }
void bch2_fs_btree_key_cache_init_early(struct btree_key_cache *c) void bch2_fs_btree_key_cache_init_early(struct btree_key_cache *c)
...@@ -622,13 +623,19 @@ void bch2_fs_btree_key_cache_init_early(struct btree_key_cache *c) ...@@ -622,13 +623,19 @@ void bch2_fs_btree_key_cache_init_early(struct btree_key_cache *c)
int bch2_fs_btree_key_cache_init(struct btree_key_cache *bc) int bch2_fs_btree_key_cache_init(struct btree_key_cache *bc)
{ {
struct bch_fs *c = container_of(bc, struct bch_fs, btree_key_cache); struct bch_fs *c = container_of(bc, struct bch_fs, btree_key_cache);
int ret;
bc->shrink.seeks = 1; bc->shrink.seeks = 1;
bc->shrink.count_objects = bch2_btree_key_cache_count; bc->shrink.count_objects = bch2_btree_key_cache_count;
bc->shrink.scan_objects = bch2_btree_key_cache_scan; bc->shrink.scan_objects = bch2_btree_key_cache_scan;
return register_shrinker(&bc->shrink, "%s/btree_key_cache", c->name) ?: ret = register_shrinker(&bc->shrink, "%s/btree_key_cache", c->name) ?:
rhashtable_init(&bc->table, &bch2_btree_key_cache_params); rhashtable_init(&bc->table, &bch2_btree_key_cache_params);
if (ret)
return ret;
bc->table_init_done = true;
return 0;
} }
void bch2_btree_key_cache_to_text(struct printbuf *out, struct btree_key_cache *c) void bch2_btree_key_cache_to_text(struct printbuf *out, struct btree_key_cache *c)
......
...@@ -293,6 +293,7 @@ static inline struct btree_iter_level *iter_l(struct btree_iter *iter) ...@@ -293,6 +293,7 @@ static inline struct btree_iter_level *iter_l(struct btree_iter *iter)
struct btree_key_cache { struct btree_key_cache {
struct mutex lock; struct mutex lock;
struct rhashtable table; struct rhashtable table;
bool table_init_done;
struct list_head freed; struct list_head freed;
struct list_head clean; struct list_head clean;
struct list_head dirty; struct list_head dirty;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment