bcachefs: Add new assertions for shutdown path

We've been seeing assertions pop that indicate the btree node cache or
key cache have dirty items when we just did a clean shutdown.

Add some more assertions so we can catch this when we're dirtying items.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
Kent Overstreet 2023-07-09 15:13:30 -04:00
parent 07f293c863
commit 30a8278a1e
2 changed files with 4 additions and 1 deletions

View file

@ -780,6 +780,7 @@ bool bch2_btree_insert_key_cached(struct btree_trans *trans,
ck->valid = true; ck->valid = true;
if (!test_bit(BKEY_CACHED_DIRTY, &ck->flags)) { if (!test_bit(BKEY_CACHED_DIRTY, &ck->flags)) {
EBUG_ON(test_bit(BCH_FS_CLEAN_SHUTDOWN, &c->flags));
set_bit(BKEY_CACHED_DIRTY, &ck->flags); set_bit(BKEY_CACHED_DIRTY, &ck->flags);
atomic_long_inc(&c->btree_key_cache.nr_dirty); atomic_long_inc(&c->btree_key_cache.nr_dirty);

View file

@ -272,8 +272,10 @@ inline void bch2_btree_insert_key_leaf(struct btree_trans *trans,
bch2_btree_add_journal_pin(c, b, journal_seq); bch2_btree_add_journal_pin(c, b, journal_seq);
if (unlikely(!btree_node_dirty(b))) if (unlikely(!btree_node_dirty(b))) {
EBUG_ON(test_bit(BCH_FS_CLEAN_SHUTDOWN, &c->flags));
set_btree_node_dirty_acct(c, b); set_btree_node_dirty_acct(c, b);
}
live_u64s_added = (int) b->nr.live_u64s - old_live_u64s; live_u64s_added = (int) b->nr.live_u64s - old_live_u64s;
u64s_added = (int) bset_u64s(t) - old_u64s; u64s_added = (int) bset_u64s(t) - old_u64s;