mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2025-01-17 13:58:46 +00:00
bcachefs: Fix bkey format calculation
For extents, we increase the number of bits of the size field to allow extents to get bigger due to merging - but this code didn't check for overflow. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
parent
c8ef8c3eb5
commit
029b85fe41
@ -591,8 +591,10 @@ struct bkey_format bch2_bkey_format_done(struct bkey_format_state *s)
|
||||
|
||||
/* allow for extent merging: */
|
||||
if (ret.bits_per_field[BKEY_FIELD_SIZE]) {
|
||||
ret.bits_per_field[BKEY_FIELD_SIZE] += 4;
|
||||
bits += 4;
|
||||
unsigned b = min(4U, 32U - ret.bits_per_field[BKEY_FIELD_SIZE]);
|
||||
|
||||
ret.bits_per_field[BKEY_FIELD_SIZE] += b;
|
||||
bits += b;
|
||||
}
|
||||
|
||||
ret.key_u64s = DIV_ROUND_UP(bits, 64);
|
||||
|
Loading…
x
Reference in New Issue
Block a user