]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
bcachefs: Ensure we don't exceed encoded_extent_max
authorKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 15:19:34 +0000 (11:19 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Tue, 31 Oct 2023 16:18:37 +0000 (12:18 -0400)
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: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/io_write.c

index 6e4f85eb6ec8ddbaa81b4201d7660712f65474a0..4a666f4d2dcc2eee761499eda9aabfda06da98ce 100644 (file)
@@ -816,6 +816,7 @@ static enum prep_encoded_ret {
 
        /* Can we just write the entire extent as is? */
        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.compression_type == bch2_compression_opt_to_type(op->compression_opt) ||
             op->incompressible)) {