diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2020-07-20 13:00:15 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 17:08:42 -0400 |
commit | e8306e3b4ca2d6cb325136afe5631247466ad176 (patch) | |
tree | bf33fc62b48fd990d949dca936b775d460cf2ebb /fs/bcachefs/io.c | |
parent | f621e1521c3ff5ea295a97d7d71cdbe84f496467 (diff) |
bcachefs: Wrap write path in memalloc_nofs_save()
This fixes a lockdep splat where we're allocating memory with vmalloc in
the compression bounce path, which doesn't always obey GFP_NOFS.
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/io.c')
-rw-r--r-- | fs/bcachefs/io.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/fs/bcachefs/io.c b/fs/bcachefs/io.c index be59b615b2db..ae2688d3aee6 100644 --- a/fs/bcachefs/io.c +++ b/fs/bcachefs/io.c @@ -32,6 +32,7 @@ #include <linux/blkdev.h> #include <linux/random.h> +#include <linux/sched/mm.h> #ifndef CONFIG_BCACHEFS_NO_LATENCY_ACCT @@ -1052,7 +1053,10 @@ static void __bch2_write(struct closure *cl) struct write_point *wp; struct bio *bio; bool skip_put = true; + unsigned nofs_flags; int ret; + + nofs_flags = memalloc_nofs_save(); again: memset(&op->failed, 0, sizeof(op->failed)); @@ -1134,13 +1138,15 @@ again: if (!skip_put) continue_at(cl, bch2_write_index, index_update_wq(op)); +out: + memalloc_nofs_restore(nofs_flags); return; err: op->error = ret; op->flags |= BCH_WRITE_DONE; continue_at(cl, bch2_write_index, index_update_wq(op)); - return; + goto out; flush_io: /* * If the write can't all be submitted at once, we generally want to @@ -1151,7 +1157,7 @@ flush_io: */ if (current->flags & PF_WQ_WORKER) { continue_at(cl, bch2_write_index, index_update_wq(op)); - return; + goto out; } closure_sync(cl); @@ -1162,7 +1168,7 @@ flush_io: if (op->error) { op->flags |= BCH_WRITE_DONE; continue_at_nobarrier(cl, bch2_write_done, NULL); - return; + goto out; } } |