Commit 5d0b7f90 authored by Kent Overstreet's avatar Kent Overstreet Committed by Kent Overstreet

bcachefs: Fix a lockdep splat

We can't allocate memory with GFP_FS while holding the btree cache lock,
and vfree() can allocate memory.
Signed-off-by: default avatarKent Overstreet <kent.overstreet@gmail.com>
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 9ba2eb25
...@@ -349,11 +349,13 @@ void bch2_fs_btree_cache_exit(struct bch_fs *c) ...@@ -349,11 +349,13 @@ void bch2_fs_btree_cache_exit(struct bch_fs *c)
{ {
struct btree_cache *bc = &c->btree_cache; struct btree_cache *bc = &c->btree_cache;
struct btree *b; struct btree *b;
unsigned i; unsigned i, flags;
if (bc->shrink.list.next) if (bc->shrink.list.next)
unregister_shrinker(&bc->shrink); unregister_shrinker(&bc->shrink);
/* vfree() can allocate memory: */
flags = memalloc_nofs_save();
mutex_lock(&bc->lock); mutex_lock(&bc->lock);
#ifdef CONFIG_BCACHEFS_DEBUG #ifdef CONFIG_BCACHEFS_DEBUG
...@@ -389,6 +391,7 @@ void bch2_fs_btree_cache_exit(struct bch_fs *c) ...@@ -389,6 +391,7 @@ void bch2_fs_btree_cache_exit(struct bch_fs *c)
} }
mutex_unlock(&bc->lock); mutex_unlock(&bc->lock);
memalloc_nofs_restore(flags);
if (bc->table_init_done) if (bc->table_init_done)
rhashtable_destroy(&bc->table); rhashtable_destroy(&bc->table);
......
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