Commit e65fcb43 authored by Kent Overstreet's avatar Kent Overstreet Committed by Kent Overstreet

bcachefs: Fix off by one error in bch2_extent_crc_append()

Signed-off-by: default avatarKent Overstreet <kent.overstreet@gmail.com>
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 7699cdd5
...@@ -344,7 +344,7 @@ enum merge_result bch2_extent_merge(struct bch_fs *c, ...@@ -344,7 +344,7 @@ enum merge_result bch2_extent_merge(struct bch_fs *c,
crc_r.uncompressed_size > c->sb.encoded_extent_max) crc_r.uncompressed_size > c->sb.encoded_extent_max)
return BCH_MERGE_NOMERGE; return BCH_MERGE_NOMERGE;
if (crc_l.uncompressed_size + crc_r.uncompressed_size - 1 > if (crc_l.uncompressed_size + crc_r.uncompressed_size >
bch2_crc_field_size_max[extent_entry_type(en_l)]) bch2_crc_field_size_max[extent_entry_type(en_l)])
return BCH_MERGE_NOMERGE; return BCH_MERGE_NOMERGE;
...@@ -562,15 +562,15 @@ void bch2_extent_crc_append(struct bkey_i *k, ...@@ -562,15 +562,15 @@ void bch2_extent_crc_append(struct bkey_i *k,
enum bch_extent_entry_type type; enum bch_extent_entry_type type;
if (bch_crc_bytes[new.csum_type] <= 4 && if (bch_crc_bytes[new.csum_type] <= 4 &&
new.uncompressed_size - 1 <= CRC32_SIZE_MAX && new.uncompressed_size <= CRC32_SIZE_MAX &&
new.nonce <= CRC32_NONCE_MAX) new.nonce <= CRC32_NONCE_MAX)
type = BCH_EXTENT_ENTRY_crc32; type = BCH_EXTENT_ENTRY_crc32;
else if (bch_crc_bytes[new.csum_type] <= 10 && else if (bch_crc_bytes[new.csum_type] <= 10 &&
new.uncompressed_size - 1 <= CRC64_SIZE_MAX && new.uncompressed_size <= CRC64_SIZE_MAX &&
new.nonce <= CRC64_NONCE_MAX) new.nonce <= CRC64_NONCE_MAX)
type = BCH_EXTENT_ENTRY_crc64; type = BCH_EXTENT_ENTRY_crc64;
else if (bch_crc_bytes[new.csum_type] <= 16 && else if (bch_crc_bytes[new.csum_type] <= 16 &&
new.uncompressed_size - 1 <= CRC128_SIZE_MAX && new.uncompressed_size <= CRC128_SIZE_MAX &&
new.nonce <= CRC128_NONCE_MAX) new.nonce <= CRC128_NONCE_MAX)
type = BCH_EXTENT_ENTRY_crc128; type = BCH_EXTENT_ENTRY_crc128;
else else
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment