bcachefs: Work around a zstd bug
authorKent Overstreet <kent.overstreet@gmail.com>
Thu, 7 Jan 2021 22:06:22 +0000 (17:06 -0500)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:08:50 +0000 (17:08 -0400)
commitfd54c40e00dc54cf1cd1724e4184502a56b9848f
tree8a19dbd9fd720ff796a536dd3838ad393860cc62
parent29d90f61eb341018ab571e7f8ceb8ff39cf5353a
bcachefs: Work around a zstd bug

The zstd compression code seems to have a bug where it will write just
past the end of the destination buffer - probably only when the
compressed output isn't going to fit in the destination buffer, which
will never happen if you're always allocating a bigger buffer than the
source buffer which would explain other users not hitting it. But, we
size the buffer according to how much contiguous space on disk we have,
so...

generally, bugs like this don't write more than a word past the end of
the buffer, so an easy workaround is to subtract a fudge factor from the
buffer size.

Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/compress.c