]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
bcachefs: Fix a lockdep splat
authorKent Overstreet <kent.overstreet@gmail.com>
Sun, 11 Oct 2020 20:33:49 +0000 (16:33 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:08:44 +0000 (17:08 -0400)
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>
fs/bcachefs/btree_cache.c

index 829bff37df8d0e1dee840aeb4b6cecc15ab12b76..5d1a7f138a5413906966a26581d72a56296f94d4 100644 (file)
@@ -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);