bcachefs: Journal keys overlay fixes
authorKent Overstreet <kent.overstreet@linux.dev>
Sun, 23 Oct 2022 21:37:23 +0000 (17:37 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:09:45 +0000 (17:09 -0400)
 - In the btree iterator code that overlays keys from the journal, we
   were incorrectly specifying level=0 instead of the btree_path's
   current level in a few places
 - When we didn't do journal replay, we shouldn't free the journal keys:
   this fixes cmd_list and cmd_dump, which run in norecovery mode

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/btree_iter.c
fs/bcachefs/recovery.c

index 611f7b0ca0146418d0f3bb9aae389642294b0316..5af295317ceed2ede707d643824b842d8909431d 100644 (file)
@@ -1834,7 +1834,7 @@ struct bkey_s_c btree_trans_peek_journal(struct btree_trans *trans,
 {
        struct bkey_i *next_journal =
                bch2_btree_journal_peek(trans, iter,
-                               k.k ? k.k->p : iter->path->l[0].b->key.k.p);
+                               k.k ? k.k->p : path_l(iter->path)->b->key.k.p);
 
        if (next_journal) {
                iter->k = next_journal->k;
index 580ff915d0e65d37fd12afe52b7d2482f24fc9d1..b2379adcf8ae186eac4e5ff28fd233f265067c6e 100644 (file)
@@ -1398,7 +1398,8 @@ out:
        set_bit(BCH_FS_FSCK_DONE, &c->flags);
        bch2_flush_fsck_errs(c);
 
-       if (!c->opts.keep_journal) {
+       if (!c->opts.keep_journal &&
+           test_bit(JOURNAL_REPLAY_DONE, &c->journal.flags)) {
                bch2_journal_keys_free(&c->journal_keys);
                bch2_journal_entries_free(c);
        }