summaryrefslogtreecommitdiff
path: root/fs/bcachefs/compress.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2020-05-22 00:23:40 +0300
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-23 00:08:39 +0300
commita1b0da4555c16bf274f705dc76c9b297f54bf6c8 (patch)
treeb11e9fe5a6f0be53777b61179dd51bd40d8bb701 /fs/bcachefs/compress.c
parent0d0e77f45fe806a80af76501d5422437692e158b (diff)
downloadlinux-a1b0da4555c16bf274f705dc76c9b297f54bf6c8.tar.xz
bcachefs: Wrap vmap() in memalloc_nofs_save()/restore()
vmalloc() and vmap() don't take GFP_NOFS - this should be pushed further up the IO path, but for now just doing the simple fix. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/compress.c')
-rw-r--r--fs/bcachefs/compress.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/fs/bcachefs/compress.c b/fs/bcachefs/compress.c
index 20bde73a17a8..6115e0294e4d 100644
--- a/fs/bcachefs/compress.c
+++ b/fs/bcachefs/compress.c
@@ -7,6 +7,7 @@
#include "super-io.h"
#include <linux/lz4.h>
+#include <linux/sched/mm.h>
#include <linux/zlib.h>
#include <linux/zstd.h>
@@ -63,7 +64,7 @@ static struct bbuf __bio_map_or_bounce(struct bch_fs *c, struct bio *bio,
struct bbuf ret;
struct bio_vec bv;
struct bvec_iter iter;
- unsigned nr_pages = 0;
+ unsigned nr_pages = 0, flags;
struct page *stack_pages[16];
struct page **pages = NULL;
void *data;
@@ -103,7 +104,10 @@ static struct bbuf __bio_map_or_bounce(struct bch_fs *c, struct bio *bio,
__bio_for_each_segment(bv, bio, iter, start)
pages[nr_pages++] = bv.bv_page;
+ flags = memalloc_nofs_save();
data = vmap(pages, nr_pages, VM_MAP, PAGE_KERNEL);
+ memalloc_nofs_restore(flags);
+
if (pages != stack_pages)
kfree(pages);