diff options
Diffstat (limited to 'fs/btrfs/volumes.c')
-rw-r--r-- | fs/btrfs/volumes.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 759d02486d7c..1411b99555a4 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c | |||
@@ -3324,12 +3324,14 @@ static int __btrfs_alloc_chunk(struct btrfs_trans_handle *trans, | |||
3324 | stripe_size = devices_info[ndevs-1].max_avail; | 3324 | stripe_size = devices_info[ndevs-1].max_avail; |
3325 | num_stripes = ndevs * dev_stripes; | 3325 | num_stripes = ndevs * dev_stripes; |
3326 | 3326 | ||
3327 | if (stripe_size * num_stripes > max_chunk_size * ncopies) { | 3327 | if (stripe_size * ndevs > max_chunk_size * ncopies) { |
3328 | stripe_size = max_chunk_size * ncopies; | 3328 | stripe_size = max_chunk_size * ncopies; |
3329 | do_div(stripe_size, num_stripes); | 3329 | do_div(stripe_size, ndevs); |
3330 | } | 3330 | } |
3331 | 3331 | ||
3332 | do_div(stripe_size, dev_stripes); | 3332 | do_div(stripe_size, dev_stripes); |
3333 | |||
3334 | /* align to BTRFS_STRIPE_LEN */ | ||
3333 | do_div(stripe_size, BTRFS_STRIPE_LEN); | 3335 | do_div(stripe_size, BTRFS_STRIPE_LEN); |
3334 | stripe_size *= BTRFS_STRIPE_LEN; | 3336 | stripe_size *= BTRFS_STRIPE_LEN; |
3335 | 3337 | ||
@@ -3805,10 +3807,11 @@ static int __btrfs_map_block(struct btrfs_mapping_tree *map_tree, int rw, | |||
3805 | else if (mirror_num) | 3807 | else if (mirror_num) |
3806 | stripe_index += mirror_num - 1; | 3808 | stripe_index += mirror_num - 1; |
3807 | else { | 3809 | else { |
3810 | int old_stripe_index = stripe_index; | ||
3808 | stripe_index = find_live_mirror(map, stripe_index, | 3811 | stripe_index = find_live_mirror(map, stripe_index, |
3809 | map->sub_stripes, stripe_index + | 3812 | map->sub_stripes, stripe_index + |
3810 | current->pid % map->sub_stripes); | 3813 | current->pid % map->sub_stripes); |
3811 | mirror_num = stripe_index + 1; | 3814 | mirror_num = stripe_index - old_stripe_index + 1; |
3812 | } | 3815 | } |
3813 | } else { | 3816 | } else { |
3814 | /* | 3817 | /* |
@@ -4350,8 +4353,10 @@ static int open_seed_devices(struct btrfs_root *root, u8 *fsid) | |||
4350 | 4353 | ||
4351 | ret = __btrfs_open_devices(fs_devices, FMODE_READ, | 4354 | ret = __btrfs_open_devices(fs_devices, FMODE_READ, |
4352 | root->fs_info->bdev_holder); | 4355 | root->fs_info->bdev_holder); |
4353 | if (ret) | 4356 | if (ret) { |
4357 | free_fs_devices(fs_devices); | ||
4354 | goto out; | 4358 | goto out; |
4359 | } | ||
4355 | 4360 | ||
4356 | if (!fs_devices->seeding) { | 4361 | if (!fs_devices->seeding) { |
4357 | __btrfs_close_devices(fs_devices); | 4362 | __btrfs_close_devices(fs_devices); |