bcachefs: Fix shutdown ordering

the btree key cache uses the srcu struct created/destroyed by
btree_iter.c; btree_iter needs to be exited last.

Reported-by: syzbot+3af9daea347788b15213@syzkaller.appspotmail.com
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
Kent Overstreet 2024-05-22 19:53:03 -04:00
parent 2195b755eb
commit d293ece108
2 changed files with 8 additions and 1 deletions

View file

@ -45,6 +45,13 @@ int bch2_printbuf_make_room(struct printbuf *out, unsigned extra)
unsigned new_size = roundup_pow_of_two(out->size + extra);
/* Sanity check... */
if (new_size > PAGE_SIZE << MAX_PAGE_ORDER) {
out->allocation_failure = true;
out->overflow = true;
return -ENOMEM;
}
/*
* Note: output buffer must be freeable with kfree(), it's not required
* that the user use printbuf_exit().

View file

@ -551,9 +551,9 @@ static void __bch2_fs_free(struct bch_fs *c)
bch2_fs_io_read_exit(c);
bch2_fs_buckets_waiting_for_journal_exit(c);
bch2_fs_btree_interior_update_exit(c);
bch2_fs_btree_iter_exit(c);
bch2_fs_btree_key_cache_exit(&c->btree_key_cache);
bch2_fs_btree_cache_exit(c);
bch2_fs_btree_iter_exit(c);
bch2_fs_replicas_exit(c);
bch2_fs_journal_exit(&c->journal);
bch2_io_clock_exit(&c->io_clock[WRITE]);