bcachefs: Issue discards when needed to allocate journal write
authorKent Overstreet <kent.overstreet@gmail.com>
Wed, 26 Feb 2020 20:58:36 +0000 (15:58 -0500)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:08:35 +0000 (17:08 -0400)
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/journal_io.c

index 1866ed30ce899bd3d685a5b699ad58cb0bc3406a..fc36385c7830ab3f7ad5f00753a52b234e70d183 100644 (file)
@@ -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():