Btrfs: fix repair code for RAID10
authorJan Schmidt <list.btrfs@jan-o-sch.net>
Fri, 27 Apr 2012 16:41:45 +0000 (12:41 -0400)
committerChris Mason <chris.mason@oracle.com>
Fri, 27 Apr 2012 17:55:13 +0000 (13:55 -0400)
btrfs_map_block sets mirror_num, so that the repair code knows eventually
which device gave us the read error. For RAID10, mirror_num must be 1 or 2.
Before this fix mirror_num was incorrectly related to our stripe index.

Signed-off-by: Jan Schmidt <list.btrfs@jan-o-sch.net>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
fs/btrfs/volumes.c

index 3b984173d25bc2ee88d86e20c3a23778850cf133..1411b99555a4c1f138a6a3bf699842849d2b3e08 100644 (file)
@@ -3807,10 +3807,11 @@ static int __btrfs_map_block(struct btrfs_mapping_tree *map_tree, int rw,
                else if (mirror_num)
                        stripe_index += mirror_num - 1;
                else {
+                       int old_stripe_index = stripe_index;
                        stripe_index = find_live_mirror(map, stripe_index,
                                              map->sub_stripes, stripe_index +
                                              current->pid % map->sub_stripes);
-                       mirror_num = stripe_index + 1;
+                       mirror_num = stripe_index - old_stripe_index + 1;
                }
        } else {
                /*