From 6a747c4683803abb01ce246ac2faf7f171cb3872 Mon Sep 17 00:00:00 2001 From: Kent Overstreet Date: Mon, 9 Nov 2020 13:01:52 -0500 Subject: bcachefs: Add accounting for dirty btree nodes/keys This lets us improve journal reclaim, so that it now tries to make sure no more than 3/4s of the btree node cache and btree key cache are dirty - ensuring the shrinkers can free memory. Signed-off-by: Kent Overstreet Signed-off-by: Kent Overstreet --- fs/bcachefs/btree_io.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'fs/bcachefs/btree_io.c') diff --git a/fs/bcachefs/btree_io.c b/fs/bcachefs/btree_io.c index c1293709eb01..0de703c5b4b7 100644 --- a/fs/bcachefs/btree_io.c +++ b/fs/bcachefs/btree_io.c @@ -1498,6 +1498,8 @@ void __bch2_btree_node_write(struct bch_fs *c, struct btree *b, new ^= (1 << BTREE_NODE_write_idx); } while (cmpxchg_acquire(&b->flags, old, new) != old); + atomic_dec(&c->btree_cache.dirty); + BUG_ON(btree_node_fake(b)); BUG_ON((b->will_make_reachable != 0) != !b->written); -- cgit v1.2.3