Skip to content

Commit 1189bdd

Browse files
author
Kent Overstreet
committed
bcachefs: Fix __bch2_btree_and_journal_iter_init_node_iter()
We weren't respecting trans->journal_replay_not_finished - we shouldn't be searching the journal keys unless we have a ref on them. Signed-off-by: Kent Overstreet <[email protected]>
1 parent 517236c commit 1189bdd

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

fs/bcachefs/btree_journal_iter.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -469,10 +469,15 @@ void __bch2_btree_and_journal_iter_init_node_iter(struct btree_trans *trans,
469469
iter->trans = trans;
470470
iter->b = b;
471471
iter->node_iter = node_iter;
472-
bch2_journal_iter_init(trans->c, &iter->journal, b->c.btree_id, b->c.level, pos);
473-
INIT_LIST_HEAD(&iter->journal.list);
474472
iter->pos = b->data->min_key;
475473
iter->at_end = false;
474+
INIT_LIST_HEAD(&iter->journal.list);
475+
476+
if (trans->journal_replay_not_finished) {
477+
bch2_journal_iter_init(trans->c, &iter->journal, b->c.btree_id, b->c.level, pos);
478+
if (!test_bit(BCH_FS_may_go_rw, &trans->c->flags))
479+
list_add(&iter->journal.list, &trans->c->journal_iters);
480+
}
476481
}
477482

478483
/*
@@ -487,9 +492,6 @@ void bch2_btree_and_journal_iter_init_node_iter(struct btree_trans *trans,
487492

488493
bch2_btree_node_iter_init_from_start(&node_iter, b);
489494
__bch2_btree_and_journal_iter_init_node_iter(trans, iter, b, node_iter, b->data->min_key);
490-
if (trans->journal_replay_not_finished &&
491-
!test_bit(BCH_FS_may_go_rw, &trans->c->flags))
492-
list_add(&iter->journal.list, &trans->c->journal_iters);
493495
}
494496

495497
/* sort and dedup all keys in the journal: */

0 commit comments

Comments
 (0)