summaryrefslogtreecommitdiff
path: root/fs/bcachefs/journal_io.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2020-02-26 15:58:36 -0500
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-22 17:08:35 -0400
commitc18dade6589ae3cec9b457849e93358bb8780fe5 (patch)
treed0704dbe22deed39905f53ba9704ed48eade24a5 /fs/bcachefs/journal_io.c
parent163e885a0aee99657b3819ead6c3390271ed0980 (diff)
downloadlwn-c18dade6589ae3cec9b457849e93358bb8780fe5.tar.gz
lwn-c18dade6589ae3cec9b457849e93358bb8780fe5.zip
bcachefs: Issue discards when needed to allocate journal write
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/journal_io.c')
-rw-r--r--fs/bcachefs/journal_io.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/fs/bcachefs/journal_io.c b/fs/bcachefs/journal_io.c
index 1866ed30ce89..fc36385c7830 100644
--- a/fs/bcachefs/journal_io.c
+++ b/fs/bcachefs/journal_io.c
@@ -1042,9 +1042,16 @@ void bch2_journal_write(struct closure *cl)
bytes = vstruct_bytes(jset);
memset((void *) jset + bytes, 0, (sectors << 9) - bytes);
+retry_alloc:
spin_lock(&j->lock);
ret = journal_write_alloc(j, w, sectors);
+ if (ret && j->can_discard) {
+ spin_unlock(&j->lock);
+ bch2_journal_do_discards(j);
+ goto retry_alloc;
+ }
+
/*
* write is allocated, no longer need to account for it in
* bch2_journal_space_available():