Commit 048f47e8 authored by Kent Overstreet's avatar Kent Overstreet

bcachefs: btree_and_journal_iter now respects trans->journal_replay_not_finished

btree_and_journal_iter is now safe to use at runtime, not just during
recovery before journal keys have been freed.
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 36f9ef10
...@@ -363,7 +363,7 @@ static void btree_and_journal_iter_prefetch(struct btree_and_journal_iter *_iter ...@@ -363,7 +363,7 @@ static void btree_and_journal_iter_prefetch(struct btree_and_journal_iter *_iter
struct bkey_s_c bch2_btree_and_journal_iter_peek(struct btree_and_journal_iter *iter) struct bkey_s_c bch2_btree_and_journal_iter_peek(struct btree_and_journal_iter *iter)
{ {
struct bkey_s_c btree_k, journal_k, ret; struct bkey_s_c btree_k, journal_k = bkey_s_c_null, ret;
if (iter->prefetch && iter->journal.level) if (iter->prefetch && iter->journal.level)
btree_and_journal_iter_prefetch(iter); btree_and_journal_iter_prefetch(iter);
...@@ -375,9 +375,10 @@ struct bkey_s_c bch2_btree_and_journal_iter_peek(struct btree_and_journal_iter * ...@@ -375,9 +375,10 @@ struct bkey_s_c bch2_btree_and_journal_iter_peek(struct btree_and_journal_iter *
bpos_lt(btree_k.k->p, iter->pos)) bpos_lt(btree_k.k->p, iter->pos))
bch2_journal_iter_advance_btree(iter); bch2_journal_iter_advance_btree(iter);
while ((journal_k = bch2_journal_iter_peek(&iter->journal)).k && if (iter->trans->journal_replay_not_finished)
bpos_lt(journal_k.k->p, iter->pos)) while ((journal_k = bch2_journal_iter_peek(&iter->journal)).k &&
bch2_journal_iter_advance(&iter->journal); bpos_lt(journal_k.k->p, iter->pos))
bch2_journal_iter_advance(&iter->journal);
ret = journal_k.k && ret = journal_k.k &&
(!btree_k.k || bpos_le(journal_k.k->p, btree_k.k->p)) (!btree_k.k || bpos_le(journal_k.k->p, btree_k.k->p))
...@@ -435,7 +436,9 @@ void bch2_btree_and_journal_iter_init_node_iter(struct btree_trans *trans, ...@@ -435,7 +436,9 @@ void bch2_btree_and_journal_iter_init_node_iter(struct btree_trans *trans,
bch2_btree_node_iter_init_from_start(&node_iter, b); bch2_btree_node_iter_init_from_start(&node_iter, b);
__bch2_btree_and_journal_iter_init_node_iter(trans, iter, b, node_iter, b->data->min_key); __bch2_btree_and_journal_iter_init_node_iter(trans, iter, b, node_iter, b->data->min_key);
list_add(&iter->journal.list, &trans->c->journal_iters); if (trans->journal_replay_not_finished &&
!test_bit(BCH_FS_may_go_rw, &trans->c->flags))
list_add(&iter->journal.list, &trans->c->journal_iters);
} }
/* sort and dedup all keys in the journal: */ /* sort and dedup all keys in the journal: */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment