summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2022-10-23 17:37:23 -0400
committerKent Overstreet <kent.overstreet@linux.dev>2022-10-24 13:38:06 -0400
commitec7cf99649b1a736b5f854dfff503f2f452cccad (patch)
tree855daeb762659f1a8f76c5ac30a27ed9b348a15d
parent36f8dcfdc8d11838f1a8340039933a9f1191d0ab (diff)
bcachefs: Journal keys overlay fixes
- 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>
-rw-r--r--fs/bcachefs/btree_iter.c5
-rw-r--r--fs/bcachefs/recovery.c3
2 files changed, 5 insertions, 3 deletions
diff --git a/fs/bcachefs/btree_iter.c b/fs/bcachefs/btree_iter.c
index 926c56c97ae0..da116153aa47 100644
--- a/fs/bcachefs/btree_iter.c
+++ b/fs/bcachefs/btree_iter.c
@@ -1803,7 +1803,8 @@ struct bkey_i *bch2_btree_journal_peek(struct btree_trans *trans,
if (bpos_cmp(start_pos, iter->journal_pos) < 0)
iter->journal_idx = 0;
- k = bch2_journal_keys_peek_upto(trans->c, iter->btree_id, 0,
+ k = bch2_journal_keys_peek_upto(trans->c, iter->btree_id,
+ iter->path->level,
start_pos, end_pos,
&iter->journal_idx);
@@ -1825,7 +1826,7 @@ struct bkey_s_c btree_trans_peek_journal(struct btree_trans *trans,
{
struct bkey_i *next_journal =
bch2_btree_journal_peek(trans, iter, iter->path->pos,
- 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;
diff --git a/fs/bcachefs/recovery.c b/fs/bcachefs/recovery.c
index 0a4568d6e62e..6968f934594f 100644
--- a/fs/bcachefs/recovery.c
+++ b/fs/bcachefs/recovery.c
@@ -1436,7 +1436,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);
}