Ensure that journal bufs that haven't been written can't be reclaimed
from the journal pin fifo, and can thus have new pins taken.

Prep work for changing the btree write buffer to pull keys from the
journal directly.

Signed-off-by: Kent Overstreet <[email protected]>
---
 fs/bcachefs/journal_io.c      | 1 +
 fs/bcachefs/journal_reclaim.c | 1 +
 2 files changed, 2 insertions(+)

diff --git a/fs/bcachefs/journal_io.c b/fs/bcachefs/journal_io.c
index 52a59770d8d0..51796454bba4 100644
--- a/fs/bcachefs/journal_io.c
+++ b/fs/bcachefs/journal_io.c
@@ -1583,6 +1583,7 @@ static void journal_write_done(struct closure *cl)
        } while ((v = atomic64_cmpxchg(&j->reservations.counter,
                                       old.v, new.v)) != old.v);
 
+       bch2_journal_reclaim_fast(j);
        bch2_journal_space_available(j);
 
        track_event_change(&c->times[BCH_TIME_blocked_journal_max_in_flight],
diff --git a/fs/bcachefs/journal_reclaim.c b/fs/bcachefs/journal_reclaim.c
index 8fa05bedb7df..67684cc5c1e5 100644
--- a/fs/bcachefs/journal_reclaim.c
+++ b/fs/bcachefs/journal_reclaim.c
@@ -303,6 +303,7 @@ void bch2_journal_reclaim_fast(struct journal *j)
         * all btree nodes got written out
         */
        while (!fifo_empty(&j->pin) &&
+              j->pin.front <= j->seq_ondisk &&
               !atomic_read(&fifo_peek_front(&j->pin).count)) {
                j->pin.front++;
                popped = true;
-- 
2.42.0


Reply via email to