]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
Btrfs: count devices correctly in readahead during RAID 5/6 replace
authorOmar Sandoval <osandov@fb.com>
Fri, 19 Jun 2015 18:52:49 +0000 (11:52 -0700)
committerChris Mason <clm@fb.com>
Sun, 9 Aug 2015 14:34:26 +0000 (07:34 -0700)
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>
fs/btrfs/reada.c

index 0e7beea92b4cc1279def4a3c61a440ec177ef1a0..4645cd16d5ba22d94396eec0f00e1243371eeb7c 100644 (file)
@@ -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;
@@ -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;