]> git.baikalelectronics.ru Git - kernel.git/commit
Btrfs: fix unexpected result when dio reading corrupted blocks
authorLiu Bo <bo.li.liu@oracle.com>
Fri, 15 Sep 2017 21:06:51 +0000 (15:06 -0600)
committerDavid Sterba <dsterba@suse.com>
Tue, 26 Sep 2017 12:54:07 +0000 (14:54 +0200)
commit5b3ebe748502af0acda2ef76d100e581a601f6e8
treea0807ca940b96170eb888a23b5bd3b159b30fa4b
parentc80067208c36b04632fde2ba510d9b15ce8df15b
Btrfs: fix unexpected result when dio reading corrupted blocks

commit 1ae364e64415 ("block: add a bi_error field to struct bio")
changed the logic of how dio read endio reports errors.

For single stripe dio read, %bio->bi_status reflects the error before
verifying checksum, and now we're updating it when data block matches
with its checksum, while in the mismatching case, %bio->bi_status is
not updated to relfect that.

When some blocks in a file have been corrupted on disk, reading such a
file ends up with

1) checksum errors are reported in kernel log
2) read(2) returns successfully with some content being 0x01.

In order to fix it, we need to report its checksum mismatch error to
the upper layer (dio layer in this case) as well.

Fixes: 1ae364e64415 ("block: add a bi_error field to struct bio")
Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
Reported-by: Goffredo Baroncelli <kreijack@inwind.it>
Tested-by: Goffredo Baroncelli <kreijack@inwind.it>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/inode.c