diff options
author | David Sterba <dsterba@suse.com> | 2018-03-20 21:29:13 -0400 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2018-05-28 12:07:26 -0400 |
commit | 1354e1a13e821040e537d5e63799df7171729945 (patch) | |
tree | cfd844d7ce857a5e29afb0add7853bcc476b17ca | |
parent | 008ef0969dd966ccb567d9c5c6e606f68119a380 (diff) |
btrfs: use mutex in btrfs_resume_balance_async
While the spinlock does not cause problems, using the mutex is more
correct and consistent with others. The global status of balance is eg.
checked from btrfs_pause_balance or btrfs_cancel_balance with mutex.
Resuming balance happens during mount or ro->rw remount. In the former
case, no other user of the balance_ctl exists, in the latter, balance
cannot run until the ro/rw transition is finished.
Reviewed-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
-rw-r--r-- | fs/btrfs/volumes.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 197b91b0e15b..447a0c275b43 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c | |||
@@ -3959,12 +3959,12 @@ int btrfs_resume_balance_async(struct btrfs_fs_info *fs_info) | |||
3959 | { | 3959 | { |
3960 | struct task_struct *tsk; | 3960 | struct task_struct *tsk; |
3961 | 3961 | ||
3962 | spin_lock(&fs_info->balance_lock); | 3962 | mutex_lock(&fs_info->balance_mutex); |
3963 | if (!fs_info->balance_ctl) { | 3963 | if (!fs_info->balance_ctl) { |
3964 | spin_unlock(&fs_info->balance_lock); | 3964 | mutex_unlock(&fs_info->balance_mutex); |
3965 | return 0; | 3965 | return 0; |
3966 | } | 3966 | } |
3967 | spin_unlock(&fs_info->balance_lock); | 3967 | mutex_unlock(&fs_info->balance_mutex); |
3968 | 3968 | ||
3969 | if (btrfs_test_opt(fs_info, SKIP_BALANCE)) { | 3969 | if (btrfs_test_opt(fs_info, SKIP_BALANCE)) { |
3970 | btrfs_info(fs_info, "force skipping balance"); | 3970 | btrfs_info(fs_info, "force skipping balance"); |