Skip to content

Commit f108ddd

Browse files
author
Kent Overstreet
committed
bcachefs: Fix shift overflow in btree_lost_data()
Reported-by: [email protected] Fixes: 55936af ("bcachefs: Flag btrees with missing data") Signed-off-by: Kent Overstreet <[email protected]>
1 parent 9667214 commit f108ddd

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

fs/bcachefs/bcachefs_format.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1555,6 +1555,12 @@ enum btree_id {
15551555
BTREE_ID_NR
15561556
};
15571557

1558+
/*
1559+
* Maximum number of btrees that we will _ever_ have under the current scheme,
1560+
* where we refer to them with bitfields
1561+
*/
1562+
#define BTREE_ID_NR_MAX 64
1563+
15581564
static inline bool btree_id_is_alloc(enum btree_id id)
15591565
{
15601566
switch (id) {

fs/bcachefs/recovery.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@
3535

3636
void bch2_btree_lost_data(struct bch_fs *c, enum btree_id btree)
3737
{
38+
if (btree >= BTREE_ID_NR_MAX)
39+
return;
40+
3841
u64 b = BIT_ULL(btree);
3942

4043
if (!(c->sb.btrees_lost_data & b)) {

0 commit comments

Comments
 (0)