diff options
author | Chris Mason <chris.mason@fusionio.com> | 2013-02-05 10:04:03 -0500 |
---|---|---|
committer | Chris Mason <chris.mason@fusionio.com> | 2013-02-05 10:04:03 -0500 |
commit | 0e4e02636611dbf89a2f36320a32054f9936d6cb (patch) | |
tree | 18b4ecc6c3812770b29729d7abbdc673ffd73a41 /fs/btrfs/volumes.c | |
parent | 1f0905ec156eec8f12cd593bc564551770319720 (diff) | |
parent | 1eafa6c73791e4f312324ddad9cbcaf6a1b6052b (diff) |
Merge branch 'for-linus' into raid56-experimental
Conflicts:
fs/btrfs/volumes.c
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
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 77620f2d8af9..8818dc34c199 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c | |||
@@ -1449,7 +1449,7 @@ int btrfs_rm_device(struct btrfs_root *root, char *device_path) | |||
1449 | } | 1449 | } |
1450 | } else { | 1450 | } else { |
1451 | ret = btrfs_get_bdev_and_sb(device_path, | 1451 | ret = btrfs_get_bdev_and_sb(device_path, |
1452 | FMODE_READ | FMODE_EXCL, | 1452 | FMODE_WRITE | FMODE_EXCL, |
1453 | root->fs_info->bdev_holder, 0, | 1453 | root->fs_info->bdev_holder, 0, |
1454 | &bdev, &bh); | 1454 | &bdev, &bh); |
1455 | if (ret) | 1455 | if (ret) |
@@ -2633,7 +2633,14 @@ static int chunk_usage_filter(struct btrfs_fs_info *fs_info, u64 chunk_offset, | |||
2633 | cache = btrfs_lookup_block_group(fs_info, chunk_offset); | 2633 | cache = btrfs_lookup_block_group(fs_info, chunk_offset); |
2634 | chunk_used = btrfs_block_group_used(&cache->item); | 2634 | chunk_used = btrfs_block_group_used(&cache->item); |
2635 | 2635 | ||
2636 | user_thresh = div_factor_fine(cache->key.offset, bargs->usage); | 2636 | if (bargs->usage == 0) |
2637 | user_thresh = 0; | ||
2638 | else if (bargs->usage > 100) | ||
2639 | user_thresh = cache->key.offset; | ||
2640 | else | ||
2641 | user_thresh = div_factor_fine(cache->key.offset, | ||
2642 | bargs->usage); | ||
2643 | |||
2637 | if (chunk_used < user_thresh) | 2644 | if (chunk_used < user_thresh) |
2638 | ret = 0; | 2645 | ret = 0; |
2639 | 2646 | ||
@@ -2982,6 +2989,8 @@ static void __cancel_balance(struct btrfs_fs_info *fs_info) | |||
2982 | unset_balance_control(fs_info); | 2989 | unset_balance_control(fs_info); |
2983 | ret = del_balance_item(fs_info->tree_root); | 2990 | ret = del_balance_item(fs_info->tree_root); |
2984 | BUG_ON(ret); | 2991 | BUG_ON(ret); |
2992 | |||
2993 | atomic_set(&fs_info->mutually_exclusive_operation_running, 0); | ||
2985 | } | 2994 | } |
2986 | 2995 | ||
2987 | void update_ioctl_balance_args(struct btrfs_fs_info *fs_info, int lock, | 2996 | void update_ioctl_balance_args(struct btrfs_fs_info *fs_info, int lock, |
@@ -3169,8 +3178,10 @@ int btrfs_balance(struct btrfs_balance_control *bctl, | |||
3169 | out: | 3178 | out: |
3170 | if (bctl->flags & BTRFS_BALANCE_RESUME) | 3179 | if (bctl->flags & BTRFS_BALANCE_RESUME) |
3171 | __cancel_balance(fs_info); | 3180 | __cancel_balance(fs_info); |
3172 | else | 3181 | else { |
3173 | kfree(bctl); | 3182 | kfree(bctl); |
3183 | atomic_set(&fs_info->mutually_exclusive_operation_running, 0); | ||
3184 | } | ||
3174 | return ret; | 3185 | return ret; |
3175 | } | 3186 | } |
3176 | 3187 | ||
@@ -3187,7 +3198,6 @@ static int balance_kthread(void *data) | |||
3187 | ret = btrfs_balance(fs_info->balance_ctl, NULL); | 3198 | ret = btrfs_balance(fs_info->balance_ctl, NULL); |
3188 | } | 3199 | } |
3189 | 3200 | ||
3190 | atomic_set(&fs_info->mutually_exclusive_operation_running, 0); | ||
3191 | mutex_unlock(&fs_info->balance_mutex); | 3201 | mutex_unlock(&fs_info->balance_mutex); |
3192 | mutex_unlock(&fs_info->volume_mutex); | 3202 | mutex_unlock(&fs_info->volume_mutex); |
3193 | 3203 | ||
@@ -3210,7 +3220,6 @@ int btrfs_resume_balance_async(struct btrfs_fs_info *fs_info) | |||
3210 | return 0; | 3220 | return 0; |
3211 | } | 3221 | } |
3212 | 3222 | ||
3213 | WARN_ON(atomic_xchg(&fs_info->mutually_exclusive_operation_running, 1)); | ||
3214 | tsk = kthread_run(balance_kthread, fs_info, "btrfs-balance"); | 3223 | tsk = kthread_run(balance_kthread, fs_info, "btrfs-balance"); |
3215 | if (IS_ERR(tsk)) | 3224 | if (IS_ERR(tsk)) |
3216 | return PTR_ERR(tsk); | 3225 | return PTR_ERR(tsk); |
@@ -3264,6 +3273,8 @@ int btrfs_recover_balance(struct btrfs_fs_info *fs_info) | |||
3264 | btrfs_balance_sys(leaf, item, &disk_bargs); | 3273 | btrfs_balance_sys(leaf, item, &disk_bargs); |
3265 | btrfs_disk_balance_args_to_cpu(&bctl->sys, &disk_bargs); | 3274 | btrfs_disk_balance_args_to_cpu(&bctl->sys, &disk_bargs); |
3266 | 3275 | ||
3276 | WARN_ON(atomic_xchg(&fs_info->mutually_exclusive_operation_running, 1)); | ||
3277 | |||
3267 | mutex_lock(&fs_info->volume_mutex); | 3278 | mutex_lock(&fs_info->volume_mutex); |
3268 | mutex_lock(&fs_info->balance_mutex); | 3279 | mutex_lock(&fs_info->balance_mutex); |
3269 | 3280 | ||
@@ -3535,7 +3546,7 @@ struct btrfs_raid_attr btrfs_raid_array[BTRFS_NR_RAID_TYPES] = { | |||
3535 | { 1, 1, 2, 2, 2, 2 /* raid1 */ }, | 3546 | { 1, 1, 2, 2, 2, 2 /* raid1 */ }, |
3536 | { 1, 2, 1, 1, 1, 2 /* dup */ }, | 3547 | { 1, 2, 1, 1, 1, 2 /* dup */ }, |
3537 | { 1, 1, 0, 2, 1, 1 /* raid0 */ }, | 3548 | { 1, 1, 0, 2, 1, 1 /* raid0 */ }, |
3538 | { 1, 1, 0, 1, 1, 1 /* single */ }, | 3549 | { 1, 1, 1, 1, 1, 1 /* single */ }, |
3539 | { 1, 1, 0, 2, 1, 2 /* raid5 */ }, | 3550 | { 1, 1, 0, 2, 1, 2 /* raid5 */ }, |
3540 | { 1, 1, 0, 3, 1, 3 /* raid6 */ }, | 3551 | { 1, 1, 0, 3, 1, 3 /* raid6 */ }, |
3541 | }; | 3552 | }; |