Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

btrfs: fix lost error return value when reading a data page

At btrfs_do_readpage(), if we get an error when trying to lookup for an
extent map, we end up marking the page with the error bit, clearing
the uptodate bit on it, and doing everything else that should be done.
However we return success (0) to the caller, when we should return the
error encoded in the extent map pointer. So fix that by returning the
error encoded in the pointer.

Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>

authored by

Filipe Manana and committed by
David Sterba
bbf0ea7e c0347550

+8 -2
+1
fs/btrfs/extent_io.c
··· 3611 3611 if (IS_ERR(em)) { 3612 3612 unlock_extent(tree, cur, end); 3613 3613 end_page_read(page, false, cur, end + 1 - cur); 3614 + ret = PTR_ERR(em); 3614 3615 break; 3615 3616 } 3616 3617 extent_offset = cur - em->start;
+7 -2
fs/btrfs/inode.c
··· 8118 8118 btrfs_lock_and_flush_ordered_range(inode, start, end, NULL); 8119 8119 8120 8120 ret = btrfs_do_readpage(page, NULL, &bio_ctrl, 0, NULL); 8121 - if (bio_ctrl.bio) 8122 - ret = submit_one_bio(bio_ctrl.bio, 0, bio_ctrl.bio_flags); 8121 + if (bio_ctrl.bio) { 8122 + int ret2; 8123 + 8124 + ret2 = submit_one_bio(bio_ctrl.bio, 0, bio_ctrl.bio_flags); 8125 + if (ret == 0) 8126 + ret = ret2; 8127 + } 8123 8128 return ret; 8124 8129 } 8125 8130