Commit 2d390812 authored by Kent Overstreet's avatar Kent Overstreet

bcachefs: Ensure we don't exceed encoded_extent_max

The write path may (rarely) see an encoded (checksummed) extent that
exceeds encoded_extent_max - this can happen when we're moving an
existing extent that was not checksummed, but was given a checksum by
bch2_write_rechecksum().
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent e677179b
...@@ -816,6 +816,7 @@ static enum prep_encoded_ret { ...@@ -816,6 +816,7 @@ static enum prep_encoded_ret {
/* Can we just write the entire extent as is? */ /* Can we just write the entire extent as is? */
if (op->crc.uncompressed_size == op->crc.live_size && if (op->crc.uncompressed_size == op->crc.live_size &&
op->crc.uncompressed_size <= c->opts.encoded_extent_max >> 9 &&
op->crc.compressed_size <= wp->sectors_free && op->crc.compressed_size <= wp->sectors_free &&
(op->crc.compression_type == bch2_compression_opt_to_type(op->compression_opt) || (op->crc.compression_type == bch2_compression_opt_to_type(op->compression_opt) ||
op->incompressible)) { op->incompressible)) {
......
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