aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorJan Schmidt <list.btrfs@jan-o-sch.net>2011-06-13 13:56:54 -0400
committerJan Schmidt <list.btrfs@jan-o-sch.net>2011-09-29 06:54:28 -0400
commit193ea74b2729e6ddc08fb6bde6e15a3bd4d94071 (patch)
tree39891ccdd556360ce016171ae18a7474dd293aeb /fs
parent558540c17771eaf89b1a3be39aa2c8bc837da1a6 (diff)
btrfs scrub: bugfix: mirror_num off by one
Fix the mirror_num determination in scrub_stripe. The rest of the scrub code did not use mirror_num for anything important and that error went unnoticed. The nodatasum fixup patch of this set depends on a correct mirror_num. Signed-off-by: Jan Schmidt <list.btrfs@jan-o-sch.net>
Diffstat (limited to 'fs')
-rw-r--r--fs/btrfs/scrub.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c
index 221fd5c48736..59caf8fcd1c7 100644
--- a/fs/btrfs/scrub.c
+++ b/fs/btrfs/scrub.c
@@ -452,7 +452,7 @@ static void scrub_fixup(struct scrub_bio *sbio, int ix)
452 * first find a good copy 452 * first find a good copy
453 */ 453 */
454 for (i = 0; i < multi->num_stripes; ++i) { 454 for (i = 0; i < multi->num_stripes; ++i) {
455 if (i == sbio->spag[ix].mirror_num) 455 if (i + 1 == sbio->spag[ix].mirror_num)
456 continue; 456 continue;
457 457
458 if (scrub_fixup_io(READ, multi->stripes[i].dev->bdev, 458 if (scrub_fixup_io(READ, multi->stripes[i].dev->bdev,
@@ -930,21 +930,21 @@ static noinline_for_stack int scrub_stripe(struct scrub_dev *sdev,
930 if (map->type & BTRFS_BLOCK_GROUP_RAID0) { 930 if (map->type & BTRFS_BLOCK_GROUP_RAID0) {
931 offset = map->stripe_len * num; 931 offset = map->stripe_len * num;
932 increment = map->stripe_len * map->num_stripes; 932 increment = map->stripe_len * map->num_stripes;
933 mirror_num = 0; 933 mirror_num = 1;
934 } else if (map->type & BTRFS_BLOCK_GROUP_RAID10) { 934 } else if (map->type & BTRFS_BLOCK_GROUP_RAID10) {
935 int factor = map->num_stripes / map->sub_stripes; 935 int factor = map->num_stripes / map->sub_stripes;
936 offset = map->stripe_len * (num / map->sub_stripes); 936 offset = map->stripe_len * (num / map->sub_stripes);
937 increment = map->stripe_len * factor; 937 increment = map->stripe_len * factor;
938 mirror_num = num % map->sub_stripes; 938 mirror_num = num % map->sub_stripes + 1;
939 } else if (map->type & BTRFS_BLOCK_GROUP_RAID1) { 939 } else if (map->type & BTRFS_BLOCK_GROUP_RAID1) {
940 increment = map->stripe_len; 940 increment = map->stripe_len;
941 mirror_num = num % map->num_stripes; 941 mirror_num = num % map->num_stripes + 1;
942 } else if (map->type & BTRFS_BLOCK_GROUP_DUP) { 942 } else if (map->type & BTRFS_BLOCK_GROUP_DUP) {
943 increment = map->stripe_len; 943 increment = map->stripe_len;
944 mirror_num = num % map->num_stripes; 944 mirror_num = num % map->num_stripes + 1;
945 } else { 945 } else {
946 increment = map->stripe_len; 946 increment = map->stripe_len;
947 mirror_num = 0; 947 mirror_num = 1;
948 } 948 }
949 949
950 path = btrfs_alloc_path(); 950 path = btrfs_alloc_path();