From: Kent Overstreet Date: Wed, 26 Feb 2020 20:58:36 +0000 (-0500) Subject: bcachefs: Issue discards when needed to allocate journal write X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=c18dade6589ae3cec9b457849e93358bb8780fe5;p=linux.git bcachefs: Issue discards when needed to allocate journal write Signed-off-by: Kent Overstreet Signed-off-by: Kent Overstreet --- diff --git a/fs/bcachefs/journal_io.c b/fs/bcachefs/journal_io.c index 1866ed30ce899..fc36385c7830a 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():