mirror of
https://github.com/torvalds/linux
synced 2024-10-16 16:29:20 +00:00
bcachefs: Put bkey invalid check in commit path in a more useful place
When doing updates early in recovery, before we can go RW, we still want to check that keys are valid at commit time - this moves key invalid checking to before the "btree updates to journal" path. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
parent
71aba59029
commit
cc07773f15
|
@ -817,25 +817,6 @@ static inline int do_bch2_trans_commit(struct btree_trans *trans, unsigned flags
|
|||
struct btree_insert_entry *i;
|
||||
int ret = 0, u64s_delta = 0;
|
||||
|
||||
#ifdef CONFIG_BCACHEFS_DEBUG
|
||||
trans_for_each_update(trans, i) {
|
||||
struct printbuf buf = PRINTBUF;
|
||||
enum bkey_invalid_flags invalid_flags = 0;
|
||||
|
||||
if (!(flags & BTREE_INSERT_JOURNAL_REPLAY))
|
||||
invalid_flags |= BKEY_INVALID_WRITE|BKEY_INVALID_COMMIT;
|
||||
|
||||
if (unlikely(bch2_bkey_invalid(c, bkey_i_to_s_c(i->k),
|
||||
i->bkey_type, invalid_flags, &buf)))
|
||||
ret = bch2_trans_commit_bkey_invalid(trans, flags, i, &buf);
|
||||
btree_insert_entry_checks(trans, i);
|
||||
printbuf_exit(&buf);
|
||||
|
||||
if (ret)
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
trans_for_each_update(trans, i) {
|
||||
if (i->cached)
|
||||
continue;
|
||||
|
@ -1048,6 +1029,25 @@ int __bch2_trans_commit(struct btree_trans *trans, unsigned flags)
|
|||
if (ret)
|
||||
goto out_reset;
|
||||
|
||||
#ifdef CONFIG_BCACHEFS_DEBUG
|
||||
trans_for_each_update(trans, i) {
|
||||
struct printbuf buf = PRINTBUF;
|
||||
enum bkey_invalid_flags invalid_flags = 0;
|
||||
|
||||
if (!(flags & BTREE_INSERT_JOURNAL_REPLAY))
|
||||
invalid_flags |= BKEY_INVALID_WRITE|BKEY_INVALID_COMMIT;
|
||||
|
||||
if (unlikely(bch2_bkey_invalid(c, bkey_i_to_s_c(i->k),
|
||||
i->bkey_type, invalid_flags, &buf)))
|
||||
ret = bch2_trans_commit_bkey_invalid(trans, flags, i, &buf);
|
||||
btree_insert_entry_checks(trans, i);
|
||||
printbuf_exit(&buf);
|
||||
|
||||
if (ret)
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (unlikely(!test_bit(BCH_FS_MAY_GO_RW, &c->flags))) {
|
||||
ret = do_bch2_trans_commit_to_journal_replay(trans);
|
||||
goto out_reset;
|
||||
|
|
Loading…
Reference in a new issue