diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2023-08-14 02:34:02 +0300 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-23 00:10:11 +0300 |
commit | 029b85fe417c36b5689093dd4861c7980299a50f (patch) | |
tree | 867c425d1a01109c30200ebb9515e293dfbbdedb /fs/bcachefs/bkey.c | |
parent | c8ef8c3eb573ae2d7f7f41d93f0e34b8f6dfcd6f (diff) | |
download | linux-029b85fe417c36b5689093dd4861c7980299a50f.tar.xz |
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>
Diffstat (limited to 'fs/bcachefs/bkey.c')
-rw-r--r-- | fs/bcachefs/bkey.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/fs/bcachefs/bkey.c b/fs/bcachefs/bkey.c index d6960e259c80..0a5bfe6e9a2d 100644 --- a/fs/bcachefs/bkey.c +++ b/fs/bcachefs/bkey.c @@ -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); |