bcachefs: Fix for journal getting stuck
authorKent Overstreet <kent.overstreet@gmail.com>
Wed, 23 Feb 2022 15:26:10 +0000 (10:26 -0500)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:09:25 +0000 (17:09 -0400)
The journal can get stuck if we need to get a journal reservation for
something we have a pre-reservation for, but aren't able to reclaim
space, or if the pin fifo is full - it's impractical to resize the pin
fifo at runtime.

Previously, we reserved 8 entries in the pin fifo for pre-reservations,
but that seems small - we're seeing the journal occasionally get stuck.
Let's reserve a quarter of it.

Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
fs/bcachefs/journal.c
fs/bcachefs/journal.h

index 3c7dce3..1f26d35 100644 (file)
@@ -416,7 +416,7 @@ unlock:
            (flags & JOURNAL_RES_GET_RESERVED)) {
                char *journal_debug_buf = kmalloc(4096, GFP_ATOMIC);
 
-               bch_err(c, "Journal stuck!");
+               bch_err(c, "Journal stuck! Hava a pre-reservation but journal full");
                if (journal_debug_buf) {
                        bch2_journal_debug_to_text(&_PBUF(journal_debug_buf, 4096), j);
                        bch_err(c, "%s", journal_debug_buf);
index 17f9037..9d4c6d8 100644 (file)
@@ -372,7 +372,7 @@ static inline bool journal_check_may_get_unreserved(struct journal *j)
 {
        union journal_preres_state s = READ_ONCE(j->prereserved);
        bool ret = s.reserved < s.remaining &&
-               fifo_free(&j->pin) > 8;
+               fifo_free(&j->pin) > j->pin.size / 4;
 
        lockdep_assert_held(&j->lock);