Skip to content

Commit 27a036a

Browse files
author
Kent Overstreet
committed
bcachefs: Fix bch_member.btree_bitmap_shift validation
Needs to match the assert later when we resize... Reported-by: [email protected] Signed-off-by: Kent Overstreet <[email protected]>
1 parent ca43f73 commit 27a036a

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

fs/bcachefs/sb-members.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ static int validate_member(struct printbuf *err,
163163
return -BCH_ERR_invalid_sb_members;
164164
}
165165

166-
if (m.btree_bitmap_shift >= 64) {
166+
if (m.btree_bitmap_shift >= BCH_MI_BTREE_BITMAP_SHIFT_MAX) {
167167
prt_printf(err, "device %u: invalid btree_bitmap_shift %u", i, m.btree_bitmap_shift);
168168
return -BCH_ERR_invalid_sb_members;
169169
}
@@ -450,7 +450,7 @@ static void __bch2_dev_btree_bitmap_mark(struct bch_sb_field_members_v2 *mi, uns
450450
m->btree_bitmap_shift += resize;
451451
}
452452

453-
BUG_ON(m->btree_bitmap_shift > 57);
453+
BUG_ON(m->btree_bitmap_shift >= BCH_MI_BTREE_BITMAP_SHIFT_MAX);
454454
BUG_ON(end > 64ULL << m->btree_bitmap_shift);
455455

456456
for (unsigned bit = start >> m->btree_bitmap_shift;

fs/bcachefs/sb-members_format.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,12 @@ struct bch_member {
6565
__le32 last_journal_bucket_offset;
6666
};
6767

68+
/*
69+
* btree_allocated_bitmap can represent sector addresses of a u64: it itself has
70+
* 64 elements, so 64 - ilog2(64)
71+
*/
72+
#define BCH_MI_BTREE_BITMAP_SHIFT_MAX 58
73+
6874
/*
6975
* This limit comes from the bucket_gens array - it's a single allocation, and
7076
* kernel allocation are limited to INT_MAX

0 commit comments

Comments
 (0)