Skip to content

Commit

Permalink
Btrfs: count devices correctly in readahead during RAID 5/6 replace
Browse files Browse the repository at this point in the history
Commit 5fbc7c5 ("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 2c8cdd6 ("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 <[email protected]>
Signed-off-by: Chris Mason <[email protected]>
  • Loading branch information
osandov authored and masoncl committed Aug 9, 2015
1 parent 03679ad commit 7cb2c42
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion fs/btrfs/reada.c
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ static struct reada_extent *reada_find_extent(struct btrfs_root *root,
struct btrfs_device *prev_dev;
u32 blocksize;
u64 length;
int real_stripes;
int nzones = 0;
int i;
unsigned long index = logical >> PAGE_CACHE_SHIFT;
Expand Down Expand Up @@ -369,7 +370,8 @@ static struct reada_extent *reada_find_extent(struct btrfs_root *root,
goto error;
}

for (nzones = 0; nzones < bbio->num_stripes; ++nzones) {
real_stripes = bbio->num_stripes - bbio->num_tgtdevs;
for (nzones = 0; nzones < real_stripes; ++nzones) {
struct reada_zone *zone;

dev = bbio->stripes[nzones].dev;
Expand Down

0 comments on commit 7cb2c42

Please sign in to comment.