Skip to content

Commit 2642084

Browse files
author
Kent Overstreet
committed
bcachefs: Allow for unknown key types in backpointers fsck
We can't assume that btrees only contain keys of a given type - even if they only have a single key type listed in the allowed key types for that btree; this is a forwards compatibility issue. Reported-by: [email protected] Signed-off-by: Kent Overstreet <[email protected]>
1 parent 0b6ec0c commit 2642084

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

fs/bcachefs/backpointers.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -952,9 +952,13 @@ int bch2_check_extents_to_backpointers(struct bch_fs *c)
952952
static int check_one_backpointer(struct btree_trans *trans,
953953
struct bbpos start,
954954
struct bbpos end,
955-
struct bkey_s_c_backpointer bp,
955+
struct bkey_s_c bp_k,
956956
struct bkey_buf *last_flushed)
957957
{
958+
if (bp_k.k->type != KEY_TYPE_backpointer)
959+
return 0;
960+
961+
struct bkey_s_c_backpointer bp = bkey_s_c_to_backpointer(bp_k);
958962
struct bch_fs *c = trans->c;
959963
struct btree_iter iter;
960964
struct bbpos pos = bp_to_bbpos(*bp.v);
@@ -1009,9 +1013,7 @@ static int bch2_check_backpointers_to_extents_pass(struct btree_trans *trans,
10091013
POS_MIN, BTREE_ITER_prefetch, k,
10101014
NULL, NULL, BCH_TRANS_COMMIT_no_enospc, ({
10111015
progress_update_iter(trans, &progress, &iter, "backpointers_to_extents");
1012-
check_one_backpointer(trans, start, end,
1013-
bkey_s_c_to_backpointer(k),
1014-
&last_flushed);
1016+
check_one_backpointer(trans, start, end, k, &last_flushed);
10151017
}));
10161018

10171019
bch2_bkey_buf_exit(&last_flushed, c);

0 commit comments

Comments
 (0)