• Nikolay Borisov's avatar
    btrfs: Always try all copies when reading extent buffers · 8732a2f4
    Nikolay Borisov authored
    commit f8397d69daef06d358430d3054662fb597e37c00 upstream.
    
    When a metadata read is served the endio routine btree_readpage_end_io_hook
    is called which eventually runs the tree-checker. If tree-checker fails
    to validate the read eb then it sets EXTENT_BUFFER_CORRUPT flag. This
    leads to btree_read_extent_buffer_pages wrongly assuming that all
    available copies of this extent buffer are wrong and failing prematurely.
    Fix this modify btree_read_extent_buffer_pages to read all copies of
    the data.
    
    This failure was exhibitted in xfstests btrfs/124 which would
    spuriously fail its balance operations. The reason was that when balance
    was run following re-introduction of the missing raid1 disk
    __btrfs_map_block would map the read request to stripe 0, which
    corresponded to devid 2 (the disk which is being removed in the test):
    
        item 2 key (FIRST_CHUNK_TREE CHUNK_ITEM 3553624064) itemoff 15975 itemsize 112
    	length 1073741824 owner 2 stripe_len 65536 type DATA|RAID1
    	io_align 65536 io_width 65536 sector_size 4096
    	num_stripes 2 sub_stripes 1
    		stripe 0 devid 2 offset 2156920832
    		dev_uuid 8466c350-ed0c-4c3b-b17d-6379b445d5c8
    		stripe 1 devid 1 offset 3553624064
    		dev_uuid 1265d8db-5596-477e-af03-df08eb38d2ca
    
    This caused read requests for a checksum item that to be routed to the
    stale disk which triggered the aforementioned logic involving
    EXTENT_BUFFER_CORRUPT flag. This then triggered cascading failures of
    the balance operation.
    
    Fixes: a826d6dc ("Btrfs: check items for correctness as we search")
    CC: stable@vger.kernel.org # 4.4+
    Suggested-by: default avatarQu Wenruo <wqu@suse.com>
    Reviewed-by: default avatarQu Wenruo <wqu@suse.com>
    Signed-off-by: default avatarNikolay Borisov <nborisov@suse.com>
    Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
    Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    8732a2f4
Name
Last commit
Last update
Documentation Loading commit data...
arch Loading commit data...
block Loading commit data...
certs Loading commit data...
crypto Loading commit data...
drivers Loading commit data...
firmware Loading commit data...
fs Loading commit data...
include Loading commit data...
init Loading commit data...
ipc Loading commit data...
kernel Loading commit data...
lib Loading commit data...
mm Loading commit data...
net Loading commit data...
samples Loading commit data...
scripts Loading commit data...
security Loading commit data...
sound Loading commit data...
tools Loading commit data...
usr Loading commit data...
virt Loading commit data...
.get_maintainer.ignore Loading commit data...
.gitignore Loading commit data...
.mailmap Loading commit data...
COPYING Loading commit data...
CREDITS Loading commit data...
Kbuild Loading commit data...
Kconfig Loading commit data...
MAINTAINERS Loading commit data...
Makefile Loading commit data...
README Loading commit data...
REPORTING-BUGS Loading commit data...