bcachefs: Ensure btree node cache is not more than half dirty
authorKent Overstreet <kent.overstreet@gmail.com>
Thu, 11 Nov 2021 20:50:22 +0000 (15:50 -0500)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:09:52 +0000 (17:09 -0400)
Tweak journal reclaim to ensure the btree node cache isn't more
than half dirty so that memory reclaim can always make progress - the
same as we do for the btree key cache.

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

index e8b7ed8e1333674c3a1f3cb30f6e624138bd7781..0f3c103e63ee1cf54bb7e263efe83a8b994050ce 100644 (file)
@@ -640,6 +640,9 @@ static int __bch2_journal_reclaim(struct journal *j, bool direct, bool kicked)
                if (fifo_free(&j->pin) <= 32)
                        min_nr = 1;
 
+               if (atomic_read(&c->btree_cache.dirty) * 2 > c->btree_cache.used)
+                       min_nr = 1;
+
                min_key_cache = min(bch2_nr_btree_keys_need_flush(c), (size_t) 128);
 
                trace_and_count(c, journal_reclaim_start, c,