On Mon, Mar 02, 2020 at 02:02:49PM -0800, Omar Sandoval wrote:
> From: Omar Sandoval <osandov@xxxxxx>
>
> btrfs_lookup_and_bind_dio_csum() does pointer arithmetic which assumes
> 32-bit checksums. If using a larger checksum, this leads to spurious
> failures when a direct I/O read crosses a stripe. This is easy
> to reproduce:
>
> # mkfs.btrfs -f --checksum BLAKE2b -d raid0 /dev/vdc /dev/vdd
> ...
> # mount /dev/vdc /mnt
> # cd /mnt
> # dd if=/dev/urandom of=foo bs=1M count=1 status=none
> # dd if=foo of=/dev/null bs=1M iflag=direct status=none
> dd: error reading 'foo': Input/output error
> # dmesg | tail -1
> [ 135.821568] BTRFS warning (device vdc): csum failed root 5 ino 257 off 421888 ...
>
> Fix it by using the actual checksum size.
>
> Fixes: 1e25a2e3ca0d ("btrfs: don't assume ordered sums to be 4 bytes")
> Signed-off-by: Omar Sandoval <osandov@xxxxxx>
> ---
> I wasn't sure what commit to point at for the fixes tag (or whether to
> just add a stable tag).
That one is fine, added to the rc queue so we can get it to stable soon.
Thanks.