Commit ef7cdac1 authored by Liu Bo's avatar Liu Bo Committed by David Sterba

Btrfs: skip checksum verification if IO error occurs

Currently dio read also goes to verify checksum if -EIO has been returned,
although it usually fails on checksum, it's not necessary at all, we could
directly check if there is another copy to read.

And with this, the behavior of dio read is now consistent with that of
buffered read.
Signed-off-by: default avatarLiu Bo <bo.li.liu@oracle.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
[ use bool for uptodate ]
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent e3d37fab
...@@ -8180,6 +8180,7 @@ static int __btrfs_subio_endio_read(struct inode *inode, ...@@ -8180,6 +8180,7 @@ static int __btrfs_subio_endio_read(struct inode *inode,
int nr_sectors; int nr_sectors;
unsigned int pgoff; unsigned int pgoff;
int csum_pos; int csum_pos;
bool uptodate = (err == 0);
int ret; int ret;
fs_info = BTRFS_I(inode)->root->fs_info; fs_info = BTRFS_I(inode)->root->fs_info;
...@@ -8195,12 +8196,13 @@ static int __btrfs_subio_endio_read(struct inode *inode, ...@@ -8195,12 +8196,13 @@ static int __btrfs_subio_endio_read(struct inode *inode,
pgoff = bvec.bv_offset; pgoff = bvec.bv_offset;
next_block: next_block:
if (uptodate) {
csum_pos = BTRFS_BYTES_TO_BLKS(fs_info, offset); csum_pos = BTRFS_BYTES_TO_BLKS(fs_info, offset);
ret = __readpage_endio_check(inode, io_bio, csum_pos, ret = __readpage_endio_check(inode, io_bio, csum_pos,
bvec.bv_page, pgoff, start, bvec.bv_page, pgoff, start, sectorsize);
sectorsize);
if (likely(!ret)) if (likely(!ret))
goto next; goto next;
}
try_again: try_again:
done.uptodate = 0; done.uptodate = 0;
done.start = start; done.start = start;
......
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