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

Btrfs: count devices correctly in readahead during RAID 5/6 replace

Commit 5fbc7c59fd22 ("Btrfs: fix unfinished readahead thread for raid5/6
degraded mounting") fixed a problem where we would skip a missing device
when we shouldn't have because there are no other mirrors to read from
in RAID 5/6. After commit 2c8cdd6ee4e7 ("Btrfs, replace: write dirty
pages into the replace target device"), the fix doesn't work when we're
doing a missing device replace on RAID 5/6 because the replace device is
counted as a mirror so we're tricked into thinking we can safely skip
the missing device. The fix is to count only the real stripes and decide
based on that.

Signed-off-by: Omar Sandoval <osandov@fb.com>
Signed-off-by: Chris Mason <clm@fb.com>

authored by

Omar Sandoval and committed by
Chris Mason
7cb2c420 03679ade

+3 -1
+3 -1
fs/btrfs/reada.c
··· 328 328 struct btrfs_device *prev_dev; 329 329 u32 blocksize; 330 330 u64 length; 331 + int real_stripes; 331 332 int nzones = 0; 332 333 int i; 333 334 unsigned long index = logical >> PAGE_CACHE_SHIFT; ··· 370 369 goto error; 371 370 } 372 371 373 - for (nzones = 0; nzones < bbio->num_stripes; ++nzones) { 372 + real_stripes = bbio->num_stripes - bbio->num_tgtdevs; 373 + for (nzones = 0; nzones < real_stripes; ++nzones) { 374 374 struct reada_zone *zone; 375 375 376 376 dev = bbio->stripes[nzones].dev;