• Omar Sandoval's avatar
    Btrfs: fix parity scrub of RAID 5/6 with missing device · 4a770891
    Omar Sandoval authored
    When testing the previous patch, Zhao Lei reported a similar bug when
    attempting to scrub a degraded RAID 5/6 filesystem with a missing
    device, leading to NULL pointer dereferences from the RAID 5/6 parity
    scrubbing code.
    
    The first cause was the same as in the previous patch: attempting to
    call bio_add_page() on a missing block device. To fix this,
    scrub_extent_for_parity() can just mark the sectors on the missing
    device as errors instead of attempting to read from it.
    
    Additionally, the code uses scrub_remap_extent() to map the extent of
    the corresponding data stripe, but the extent wasn't already mapped. If
    scrub_remap_extent() finds a missing block device, it doesn't initialize
    extent_dev, so we're left with a NULL struct btrfs_device. The solution
    is to use btrfs_map_block() directly.
    Reported-by: default avatarZhao Lei <zhaolei@cn.fujitsu.com>
    Signed-off-by: default avatarOmar Sandoval <osandov@fb.com>
    Signed-off-by: default avatarChris Mason <clm@fb.com>
    4a770891
scrub.c 115 KB