summaryrefslogtreecommitdiff
path: root/fs/bcachefs/btree_cache.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2020-10-11 16:33:49 -0400
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-22 17:08:44 -0400
commit5d0b7f906a7e047768f86539b10df602fcbd44b8 (patch)
tree7cade10aca852f374913784360518f492f5a4548 /fs/bcachefs/btree_cache.c
parent9ba2eb25f017800c3d00eac2bbc3c99451c3bae2 (diff)
downloadlwn-5d0b7f906a7e047768f86539b10df602fcbd44b8.tar.gz
lwn-5d0b7f906a7e047768f86539b10df602fcbd44b8.zip
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: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/btree_cache.c')
-rw-r--r--fs/bcachefs/btree_cache.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/fs/bcachefs/btree_cache.c b/fs/bcachefs/btree_cache.c
index 829bff37df8d..5d1a7f138a54 100644
--- a/fs/bcachefs/btree_cache.c
+++ b/fs/bcachefs/btree_cache.c
@@ -349,11 +349,13 @@ void bch2_fs_btree_cache_exit(struct bch_fs *c)
{
struct btree_cache *bc = &c->btree_cache;
struct btree *b;
- unsigned i;
+ unsigned i, flags;
if (bc->shrink.list.next)
unregister_shrinker(&bc->shrink);
+ /* vfree() can allocate memory: */
+ flags = memalloc_nofs_save();
mutex_lock(&bc->lock);
#ifdef CONFIG_BCACHEFS_DEBUG
@@ -389,6 +391,7 @@ void bch2_fs_btree_cache_exit(struct bch_fs *c)
}
mutex_unlock(&bc->lock);
+ memalloc_nofs_restore(flags);
if (bc->table_init_done)
rhashtable_destroy(&bc->table);