Btrfs: fix parity scrub of RAID 5/6 with missing device
authorOmar Sandoval <osandov@fb.com>
Fri, 19 Jun 2015 18:52:52 +0000 (11:52 -0700)
committerChris Mason <clm@fb.com>
Sun, 9 Aug 2015 14:34:26 +0000 (07:34 -0700)
commit4a770891d9ddf94df985ca438e78d355b8469247
tree76ed4ed34130103c9467142d2444bada3e1150ce
parent73ff61dbe5edeb1799d7e91c8b0641f87feb75fa
Btrfs: fix parity scrub of RAID 5/6 with missing device

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: Zhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: Omar Sandoval <osandov@fb.com>
Signed-off-by: Chris Mason <clm@fb.com>
fs/btrfs/scrub.c