Skip to content

Commit 9623224

Browse files
author
Kent Overstreet
committed
bcachefs: Handle backpointers with unknown data types
New data types might be added later, so we don't want to disallow unknown data types - that'll be a compatibility hassle later. Instead, ignore them. Reported-by: [email protected] Signed-off-by: Kent Overstreet <[email protected]>
1 parent 6a9f681 commit 9623224

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

fs/bcachefs/backpointers.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -784,7 +784,7 @@ enum alloc_sector_counter {
784784
ALLOC_SECTORS_NR
785785
};
786786

787-
static enum alloc_sector_counter data_type_to_alloc_counter(enum bch_data_type t)
787+
static int data_type_to_alloc_counter(enum bch_data_type t)
788788
{
789789
switch (t) {
790790
case BCH_DATA_btree:
@@ -796,7 +796,7 @@ static enum alloc_sector_counter data_type_to_alloc_counter(enum bch_data_type t
796796
case BCH_DATA_parity:
797797
return ALLOC_stripe;
798798
default:
799-
BUG();
799+
return -1;
800800
}
801801
}
802802

@@ -847,7 +847,11 @@ static int check_bucket_backpointer_mismatch(struct btree_trans *trans, struct b
847847
if (bp.v->bucket_gen != a->gen)
848848
continue;
849849

850-
sectors[data_type_to_alloc_counter(bp.v->data_type)] += bp.v->bucket_len;
850+
int alloc_counter = data_type_to_alloc_counter(bp.v->data_type);
851+
if (alloc_counter < 0)
852+
continue;
853+
854+
sectors[alloc_counter] += bp.v->bucket_len;
851855
};
852856
bch2_trans_iter_exit(trans, &iter);
853857
if (ret)

0 commit comments

Comments
 (0)