diff options
Diffstat (limited to 'fs/btrfs/volumes.c')
-rw-r--r-- | fs/btrfs/volumes.c | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index d712c46c0a6b..bf38ed09810a 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c | |||
@@ -4994,7 +4994,7 @@ static int __btrfs_map_block(struct btrfs_fs_info *fs_info, int rw, | |||
4994 | * stripe_nr counts the total number of stripes we have to stride | 4994 | * stripe_nr counts the total number of stripes we have to stride |
4995 | * to get to this block | 4995 | * to get to this block |
4996 | */ | 4996 | */ |
4997 | do_div(stripe_nr, stripe_len); | 4997 | stripe_nr = div64_u64(stripe_nr, stripe_len); |
4998 | 4998 | ||
4999 | stripe_offset = stripe_nr * stripe_len; | 4999 | stripe_offset = stripe_nr * stripe_len; |
5000 | BUG_ON(offset < stripe_offset); | 5000 | BUG_ON(offset < stripe_offset); |
@@ -5010,7 +5010,8 @@ static int __btrfs_map_block(struct btrfs_fs_info *fs_info, int rw, | |||
5010 | /* allow a write of a full stripe, but make sure we don't | 5010 | /* allow a write of a full stripe, but make sure we don't |
5011 | * allow straddling of stripes | 5011 | * allow straddling of stripes |
5012 | */ | 5012 | */ |
5013 | do_div(raid56_full_stripe_start, full_stripe_len); | 5013 | raid56_full_stripe_start = div64_u64(raid56_full_stripe_start, |
5014 | full_stripe_len); | ||
5014 | raid56_full_stripe_start *= full_stripe_len; | 5015 | raid56_full_stripe_start *= full_stripe_len; |
5015 | } | 5016 | } |
5016 | 5017 | ||
@@ -5143,7 +5144,8 @@ static int __btrfs_map_block(struct btrfs_fs_info *fs_info, int rw, | |||
5143 | if (rw & REQ_DISCARD) | 5144 | if (rw & REQ_DISCARD) |
5144 | num_stripes = min_t(u64, map->num_stripes, | 5145 | num_stripes = min_t(u64, map->num_stripes, |
5145 | stripe_nr_end - stripe_nr_orig); | 5146 | stripe_nr_end - stripe_nr_orig); |
5146 | stripe_index = do_div(stripe_nr, map->num_stripes); | 5147 | stripe_nr = div_u64_rem(stripe_nr, map->num_stripes, |
5148 | &stripe_index); | ||
5147 | if (!(rw & (REQ_WRITE | REQ_DISCARD | REQ_GET_READ_MIRRORS))) | 5149 | if (!(rw & (REQ_WRITE | REQ_DISCARD | REQ_GET_READ_MIRRORS))) |
5148 | mirror_num = 1; | 5150 | mirror_num = 1; |
5149 | } else if (map->type & BTRFS_BLOCK_GROUP_RAID1) { | 5151 | } else if (map->type & BTRFS_BLOCK_GROUP_RAID1) { |
@@ -5171,7 +5173,7 @@ static int __btrfs_map_block(struct btrfs_fs_info *fs_info, int rw, | |||
5171 | } else if (map->type & BTRFS_BLOCK_GROUP_RAID10) { | 5173 | } else if (map->type & BTRFS_BLOCK_GROUP_RAID10) { |
5172 | int factor = map->num_stripes / map->sub_stripes; | 5174 | int factor = map->num_stripes / map->sub_stripes; |
5173 | 5175 | ||
5174 | stripe_index = do_div(stripe_nr, factor); | 5176 | stripe_nr = div_u64_rem(stripe_nr, factor, &stripe_index); |
5175 | stripe_index *= map->sub_stripes; | 5177 | stripe_index *= map->sub_stripes; |
5176 | 5178 | ||
5177 | if (rw & (REQ_WRITE | REQ_GET_READ_MIRRORS)) | 5179 | if (rw & (REQ_WRITE | REQ_GET_READ_MIRRORS)) |
@@ -5208,32 +5210,32 @@ static int __btrfs_map_block(struct btrfs_fs_info *fs_info, int rw, | |||
5208 | stripe_index = 0; | 5210 | stripe_index = 0; |
5209 | stripe_offset = 0; | 5211 | stripe_offset = 0; |
5210 | } else { | 5212 | } else { |
5211 | u64 tmp; | ||
5212 | |||
5213 | /* | 5213 | /* |
5214 | * Mirror #0 or #1 means the original data block. | 5214 | * Mirror #0 or #1 means the original data block. |
5215 | * Mirror #2 is RAID5 parity block. | 5215 | * Mirror #2 is RAID5 parity block. |
5216 | * Mirror #3 is RAID6 Q block. | 5216 | * Mirror #3 is RAID6 Q block. |
5217 | */ | 5217 | */ |
5218 | stripe_index = do_div(stripe_nr, nr_data_stripes(map)); | 5218 | stripe_nr = div_u64_rem(stripe_nr, |
5219 | nr_data_stripes(map), &stripe_index); | ||
5219 | if (mirror_num > 1) | 5220 | if (mirror_num > 1) |
5220 | stripe_index = nr_data_stripes(map) + | 5221 | stripe_index = nr_data_stripes(map) + |
5221 | mirror_num - 2; | 5222 | mirror_num - 2; |
5222 | 5223 | ||
5223 | /* We distribute the parity blocks across stripes */ | 5224 | /* We distribute the parity blocks across stripes */ |
5224 | tmp = stripe_nr + stripe_index; | 5225 | div_u64_rem(stripe_nr + stripe_index, map->num_stripes, |
5225 | stripe_index = do_div(tmp, map->num_stripes); | 5226 | &stripe_index); |
5226 | if (!(rw & (REQ_WRITE | REQ_DISCARD | | 5227 | if (!(rw & (REQ_WRITE | REQ_DISCARD | |
5227 | REQ_GET_READ_MIRRORS)) && mirror_num <= 1) | 5228 | REQ_GET_READ_MIRRORS)) && mirror_num <= 1) |
5228 | mirror_num = 1; | 5229 | mirror_num = 1; |
5229 | } | 5230 | } |
5230 | } else { | 5231 | } else { |
5231 | /* | 5232 | /* |
5232 | * after this do_div call, stripe_nr is the number of stripes | 5233 | * after this, stripe_nr is the number of stripes on this |
5233 | * on this device we have to walk to find the data, and | 5234 | * device we have to walk to find the data, and stripe_index is |
5234 | * stripe_index is the number of our device in the stripe array | 5235 | * the number of our device in the stripe array |
5235 | */ | 5236 | */ |
5236 | stripe_index = do_div(stripe_nr, map->num_stripes); | 5237 | stripe_nr = div_u64_rem(stripe_nr, map->num_stripes, |
5238 | &stripe_index); | ||
5237 | mirror_num = stripe_index + 1; | 5239 | mirror_num = stripe_index + 1; |
5238 | } | 5240 | } |
5239 | BUG_ON(stripe_index >= map->num_stripes); | 5241 | BUG_ON(stripe_index >= map->num_stripes); |
@@ -5268,8 +5270,7 @@ static int __btrfs_map_block(struct btrfs_fs_info *fs_info, int rw, | |||
5268 | sizeof(int) * tgtdev_indexes); | 5270 | sizeof(int) * tgtdev_indexes); |
5269 | 5271 | ||
5270 | /* Work out the disk rotation on this stripe-set */ | 5272 | /* Work out the disk rotation on this stripe-set */ |
5271 | tmp = stripe_nr; | 5273 | div_u64_rem(stripe_nr, num_stripes, &rot); |
5272 | rot = do_div(tmp, num_stripes); | ||
5273 | 5274 | ||
5274 | /* Fill in the logical address of each stripe */ | 5275 | /* Fill in the logical address of each stripe */ |
5275 | tmp = stripe_nr * nr_data_stripes(map); | 5276 | tmp = stripe_nr * nr_data_stripes(map); |