diff options
author | Stefan Behrens <sbehrens@giantdisaster.de> | 2012-11-05 11:54:08 -0500 |
---|---|---|
committer | Josef Bacik <jbacik@fusionio.com> | 2012-12-12 17:15:38 -0500 |
commit | 5ac00addc7ac09110995fe967071d191b5981cc1 (patch) | |
tree | a5290cc4e69c434b24c091a212d1723bae56e46c /fs/btrfs/volumes.c | |
parent | a2bff64025d7a707ac49155bb6678a636e55096e (diff) |
Btrfs: disallow mutually exclusive admin operations from user mode
Btrfs admin operations that are manually started from user mode
and that cannot be executed at the same time return -EINPROGRESS.
A common way to enter and leave this locked section is introduced
since it used to be specific to the balance operation.
Signed-off-by: Stefan Behrens <sbehrens@giantdisaster.de>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Diffstat (limited to 'fs/btrfs/volumes.c')
-rw-r--r-- | fs/btrfs/volumes.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index d2c0bccca607..33ca36b37a6a 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c | |||
@@ -2952,6 +2952,7 @@ static int balance_kthread(void *data) | |||
2952 | ret = btrfs_balance(fs_info->balance_ctl, NULL); | 2952 | ret = btrfs_balance(fs_info->balance_ctl, NULL); |
2953 | } | 2953 | } |
2954 | 2954 | ||
2955 | atomic_set(&fs_info->mutually_exclusive_operation_running, 0); | ||
2955 | mutex_unlock(&fs_info->balance_mutex); | 2956 | mutex_unlock(&fs_info->balance_mutex); |
2956 | mutex_unlock(&fs_info->volume_mutex); | 2957 | mutex_unlock(&fs_info->volume_mutex); |
2957 | 2958 | ||
@@ -2974,6 +2975,7 @@ int btrfs_resume_balance_async(struct btrfs_fs_info *fs_info) | |||
2974 | return 0; | 2975 | return 0; |
2975 | } | 2976 | } |
2976 | 2977 | ||
2978 | WARN_ON(atomic_xchg(&fs_info->mutually_exclusive_operation_running, 1)); | ||
2977 | tsk = kthread_run(balance_kthread, fs_info, "btrfs-balance"); | 2979 | tsk = kthread_run(balance_kthread, fs_info, "btrfs-balance"); |
2978 | if (IS_ERR(tsk)) | 2980 | if (IS_ERR(tsk)) |
2979 | return PTR_ERR(tsk); | 2981 | return PTR_ERR(tsk); |