From 4e4758c6cbbbc31aad9ec733c6f49a7221fd7b70 Mon Sep 17 00:00:00 2001 From: Kent Overstreet Date: Fri, 27 Mar 2020 17:38:51 -0400 Subject: [PATCH] bcachefs: Use memalloc_nofs_save() vmalloc allocations don't always obey GFP_NOFS - memalloc_nofs_save() is the prefered approach for the future. Signed-off-by: Kent Overstreet Signed-off-by: Kent Overstreet --- fs/bcachefs/btree_io.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/fs/bcachefs/btree_io.c b/fs/bcachefs/btree_io.c index e43d1b2ce5c7a..85a17225a68e9 100644 --- a/fs/bcachefs/btree_io.c +++ b/fs/bcachefs/btree_io.c @@ -20,6 +20,8 @@ #include "super-io.h" #include "trace.h" +#include + static void verify_no_dups(struct btree *b, struct bkey_packed *start, struct bkey_packed *end, @@ -67,17 +69,19 @@ static void btree_bounce_free(struct bch_fs *c, unsigned order, static void *btree_bounce_alloc(struct bch_fs *c, unsigned order, bool *used_mempool) { + unsigned flags = memalloc_nofs_save(); void *p; BUG_ON(order > btree_page_order(c)); *used_mempool = false; p = (void *) __get_free_pages(__GFP_NOWARN|GFP_NOWAIT, order); - if (p) - return p; - - *used_mempool = true; - return mempool_alloc(&c->btree_bounce_pool, GFP_NOIO); + if (!p) { + *used_mempool = true; + p = mempool_alloc(&c->btree_bounce_pool, GFP_NOIO); + } + memalloc_nofs_restore(flags); + return p; } static void sort_bkey_ptrs(const struct btree *bt, -- 2.30.2