diff options
Diffstat (limited to 'fs/btrfs/volumes.c')
-rw-r--r-- | fs/btrfs/volumes.c | 23 |
1 files changed, 7 insertions, 16 deletions
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 460240706505..107fc74c3ab8 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c | |||
@@ -1029,19 +1029,8 @@ again: | |||
1029 | else if (mirror_num) { | 1029 | else if (mirror_num) { |
1030 | stripe_index = mirror_num - 1; | 1030 | stripe_index = mirror_num - 1; |
1031 | } else { | 1031 | } else { |
1032 | int i; | 1032 | u64 orig_stripe_nr = stripe_nr; |
1033 | u64 least = (u64)-1; | 1033 | stripe_index = do_div(orig_stripe_nr, num_stripes); |
1034 | struct btrfs_device *cur; | ||
1035 | |||
1036 | for (i = 0; i < map->num_stripes; i++) { | ||
1037 | cur = map->stripes[i].dev; | ||
1038 | spin_lock(&cur->io_lock); | ||
1039 | if (cur->total_ios < least) { | ||
1040 | least = cur->total_ios; | ||
1041 | stripe_index = i; | ||
1042 | } | ||
1043 | spin_unlock(&cur->io_lock); | ||
1044 | } | ||
1045 | } | 1034 | } |
1046 | } else if (map->type & BTRFS_BLOCK_GROUP_DUP) { | 1035 | } else if (map->type & BTRFS_BLOCK_GROUP_DUP) { |
1047 | if (rw & (1 << BIO_RW)) | 1036 | if (rw & (1 << BIO_RW)) |
@@ -1050,7 +1039,6 @@ again: | |||
1050 | stripe_index = mirror_num - 1; | 1039 | stripe_index = mirror_num - 1; |
1051 | } else if (map->type & BTRFS_BLOCK_GROUP_RAID10) { | 1040 | } else if (map->type & BTRFS_BLOCK_GROUP_RAID10) { |
1052 | int factor = map->num_stripes / map->sub_stripes; | 1041 | int factor = map->num_stripes / map->sub_stripes; |
1053 | int orig_stripe_nr = stripe_nr; | ||
1054 | 1042 | ||
1055 | stripe_index = do_div(stripe_nr, factor); | 1043 | stripe_index = do_div(stripe_nr, factor); |
1056 | stripe_index *= map->sub_stripes; | 1044 | stripe_index *= map->sub_stripes; |
@@ -1059,8 +1047,11 @@ again: | |||
1059 | num_stripes = map->sub_stripes; | 1047 | num_stripes = map->sub_stripes; |
1060 | else if (mirror_num) | 1048 | else if (mirror_num) |
1061 | stripe_index += mirror_num - 1; | 1049 | stripe_index += mirror_num - 1; |
1062 | else | 1050 | else { |
1063 | stripe_index += orig_stripe_nr % map->sub_stripes; | 1051 | u64 orig_stripe_nr = stripe_nr; |
1052 | stripe_index += do_div(orig_stripe_nr, | ||
1053 | map->sub_stripes); | ||
1054 | } | ||
1064 | } else { | 1055 | } else { |
1065 | /* | 1056 | /* |
1066 | * after this do_div call, stripe_nr is the number of stripes | 1057 | * after this do_div call, stripe_nr is the number of stripes |