diff options
author | Chris Mason <chris.mason@fusionio.com> | 2013-02-05 19:24:44 -0500 |
---|---|---|
committer | Chris Mason <chris.mason@fusionio.com> | 2013-02-05 19:24:44 -0500 |
commit | 24f8ebe9189c91f1b3ecfaadd27ef0cb7c74907f (patch) | |
tree | 80856cf81ec5cb377f7d871233dad0f0283a0c97 /fs/btrfs/volumes.c | |
parent | 3c911608085bf2d5a0822c418129f96a2a89d1b5 (diff) | |
parent | 59fe4f41976f6331b695ff049296d082cf621823 (diff) |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/josef/btrfs-next.git for-chris into for-linus
Diffstat (limited to 'fs/btrfs/volumes.c')
-rw-r--r-- | fs/btrfs/volumes.c | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 485a5423e3c6..5cbb7f4b1672 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c | |||
@@ -1431,7 +1431,7 @@ int btrfs_rm_device(struct btrfs_root *root, char *device_path) | |||
1431 | } | 1431 | } |
1432 | } else { | 1432 | } else { |
1433 | ret = btrfs_get_bdev_and_sb(device_path, | 1433 | ret = btrfs_get_bdev_and_sb(device_path, |
1434 | FMODE_READ | FMODE_EXCL, | 1434 | FMODE_WRITE | FMODE_EXCL, |
1435 | root->fs_info->bdev_holder, 0, | 1435 | root->fs_info->bdev_holder, 0, |
1436 | &bdev, &bh); | 1436 | &bdev, &bh); |
1437 | if (ret) | 1437 | if (ret) |
@@ -2615,7 +2615,14 @@ static int chunk_usage_filter(struct btrfs_fs_info *fs_info, u64 chunk_offset, | |||
2615 | cache = btrfs_lookup_block_group(fs_info, chunk_offset); | 2615 | cache = btrfs_lookup_block_group(fs_info, chunk_offset); |
2616 | chunk_used = btrfs_block_group_used(&cache->item); | 2616 | chunk_used = btrfs_block_group_used(&cache->item); |
2617 | 2617 | ||
2618 | user_thresh = div_factor_fine(cache->key.offset, bargs->usage); | 2618 | if (bargs->usage == 0) |
2619 | user_thresh = 0; | ||
2620 | else if (bargs->usage > 100) | ||
2621 | user_thresh = cache->key.offset; | ||
2622 | else | ||
2623 | user_thresh = div_factor_fine(cache->key.offset, | ||
2624 | bargs->usage); | ||
2625 | |||
2619 | if (chunk_used < user_thresh) | 2626 | if (chunk_used < user_thresh) |
2620 | ret = 0; | 2627 | ret = 0; |
2621 | 2628 | ||
@@ -2960,6 +2967,8 @@ static void __cancel_balance(struct btrfs_fs_info *fs_info) | |||
2960 | unset_balance_control(fs_info); | 2967 | unset_balance_control(fs_info); |
2961 | ret = del_balance_item(fs_info->tree_root); | 2968 | ret = del_balance_item(fs_info->tree_root); |
2962 | BUG_ON(ret); | 2969 | BUG_ON(ret); |
2970 | |||
2971 | atomic_set(&fs_info->mutually_exclusive_operation_running, 0); | ||
2963 | } | 2972 | } |
2964 | 2973 | ||
2965 | void update_ioctl_balance_args(struct btrfs_fs_info *fs_info, int lock, | 2974 | void update_ioctl_balance_args(struct btrfs_fs_info *fs_info, int lock, |
@@ -3139,8 +3148,10 @@ int btrfs_balance(struct btrfs_balance_control *bctl, | |||
3139 | out: | 3148 | out: |
3140 | if (bctl->flags & BTRFS_BALANCE_RESUME) | 3149 | if (bctl->flags & BTRFS_BALANCE_RESUME) |
3141 | __cancel_balance(fs_info); | 3150 | __cancel_balance(fs_info); |
3142 | else | 3151 | else { |
3143 | kfree(bctl); | 3152 | kfree(bctl); |
3153 | atomic_set(&fs_info->mutually_exclusive_operation_running, 0); | ||
3154 | } | ||
3144 | return ret; | 3155 | return ret; |
3145 | } | 3156 | } |
3146 | 3157 | ||
@@ -3157,7 +3168,6 @@ static int balance_kthread(void *data) | |||
3157 | ret = btrfs_balance(fs_info->balance_ctl, NULL); | 3168 | ret = btrfs_balance(fs_info->balance_ctl, NULL); |
3158 | } | 3169 | } |
3159 | 3170 | ||
3160 | atomic_set(&fs_info->mutually_exclusive_operation_running, 0); | ||
3161 | mutex_unlock(&fs_info->balance_mutex); | 3171 | mutex_unlock(&fs_info->balance_mutex); |
3162 | mutex_unlock(&fs_info->volume_mutex); | 3172 | mutex_unlock(&fs_info->volume_mutex); |
3163 | 3173 | ||
@@ -3180,7 +3190,6 @@ int btrfs_resume_balance_async(struct btrfs_fs_info *fs_info) | |||
3180 | return 0; | 3190 | return 0; |
3181 | } | 3191 | } |
3182 | 3192 | ||
3183 | WARN_ON(atomic_xchg(&fs_info->mutually_exclusive_operation_running, 1)); | ||
3184 | tsk = kthread_run(balance_kthread, fs_info, "btrfs-balance"); | 3193 | tsk = kthread_run(balance_kthread, fs_info, "btrfs-balance"); |
3185 | if (IS_ERR(tsk)) | 3194 | if (IS_ERR(tsk)) |
3186 | return PTR_ERR(tsk); | 3195 | return PTR_ERR(tsk); |
@@ -3234,6 +3243,8 @@ int btrfs_recover_balance(struct btrfs_fs_info *fs_info) | |||
3234 | btrfs_balance_sys(leaf, item, &disk_bargs); | 3243 | btrfs_balance_sys(leaf, item, &disk_bargs); |
3235 | btrfs_disk_balance_args_to_cpu(&bctl->sys, &disk_bargs); | 3244 | btrfs_disk_balance_args_to_cpu(&bctl->sys, &disk_bargs); |
3236 | 3245 | ||
3246 | WARN_ON(atomic_xchg(&fs_info->mutually_exclusive_operation_running, 1)); | ||
3247 | |||
3237 | mutex_lock(&fs_info->volume_mutex); | 3248 | mutex_lock(&fs_info->volume_mutex); |
3238 | mutex_lock(&fs_info->balance_mutex); | 3249 | mutex_lock(&fs_info->balance_mutex); |
3239 | 3250 | ||
@@ -3497,7 +3508,7 @@ struct btrfs_raid_attr btrfs_raid_array[BTRFS_NR_RAID_TYPES] = { | |||
3497 | { 1, 1, 2, 2, 2, 2 /* raid1 */ }, | 3508 | { 1, 1, 2, 2, 2, 2 /* raid1 */ }, |
3498 | { 1, 2, 1, 1, 1, 2 /* dup */ }, | 3509 | { 1, 2, 1, 1, 1, 2 /* dup */ }, |
3499 | { 1, 1, 0, 2, 1, 1 /* raid0 */ }, | 3510 | { 1, 1, 0, 2, 1, 1 /* raid0 */ }, |
3500 | { 1, 1, 0, 1, 1, 1 /* single */ }, | 3511 | { 1, 1, 1, 1, 1, 1 /* single */ }, |
3501 | }; | 3512 | }; |
3502 | 3513 | ||
3503 | static int __btrfs_alloc_chunk(struct btrfs_trans_handle *trans, | 3514 | static int __btrfs_alloc_chunk(struct btrfs_trans_handle *trans, |