Skip to content

Commit

Permalink
bcachefs: Wrap vmap() in memalloc_nofs_save()/restore()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
koverstreet committed May 21, 2020
1 parent e1f6739 commit 8b23a1b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion fs/bcachefs/compress.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit 8b23a1b

Please sign in to comment.