bcachefs: use memalloc_nofs_save() for vmalloc allocation
authorKent Overstreet <kent.overstreet@gmail.com>
Wed, 12 Jun 2019 01:03:23 +0000 (21:03 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:08:23 +0000 (17:08 -0400)
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/btree_cache.c

index d80ba1d718263afab046a1f79669488cfce524d4..ea775d91de6769d2d050144946ad71ad21f82610 100644 (file)
@@ -9,6 +9,7 @@
 #include "trace.h"
 
 #include <linux/prefetch.h>
+#include <linux/sched/mm.h>
 
 const char * const bch2_btree_ids[] = {
 #define x(kwd, val, name) name,
@@ -509,7 +510,9 @@ struct btree *bch2_btree_node_mem_alloc(struct bch_fs *c)
        struct btree_cache *bc = &c->btree_cache;
        struct btree *b;
        u64 start_time = local_clock();
+       unsigned flags;
 
+       flags = memalloc_nofs_save();
        mutex_lock(&bc->lock);
 
        /*
@@ -547,6 +550,7 @@ out_unlock:
 
        list_del_init(&b->list);
        mutex_unlock(&bc->lock);
+       memalloc_nofs_restore(flags);
 out:
        b->flags                = 0;
        b->written              = 0;