Skip to content
This repository has been archived by the owner on Sep 24, 2020. It is now read-only.

Commit

Permalink
btrfs: move clearing of EXCL_OP out of __cancel_balance
Browse files Browse the repository at this point in the history
Make the clearning visible in the callers so we can pair it with the
test_and_set part.

Signed-off-by: David Sterba <dsterba@suse.com>
  • Loading branch information
kdave committed May 28, 2018
1 parent 72b81ab commit a17c95d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion fs/btrfs/ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -4462,7 +4462,7 @@ static long btrfs_ioctl_balance(struct file *file, void __user *arg)
* Ownership of bctl and filesystem flag BTRFS_FS_EXCL_OP
* goes to to btrfs_balance. bctl is freed in __cancel_balance,
* or, if restriper was paused all the way until unmount, in
* free_fs_info. The flag is cleared in __cancel_balance.
* free_fs_info. The flag should be cleared after __cancel_balance.
*/
need_unlock = false;

Expand Down
13 changes: 7 additions & 6 deletions fs/btrfs/volumes.c
Original file line number Diff line number Diff line change
Expand Up @@ -3780,8 +3780,6 @@ static void __cancel_balance(struct btrfs_fs_info *fs_info)
ret = del_balance_item(fs_info);
if (ret)
btrfs_handle_fs_error(fs_info, ret, NULL);

clear_bit(BTRFS_FS_EXCL_OP, &fs_info->flags);
}

/* Non-zero return value signifies invalidity */
Expand Down Expand Up @@ -3939,6 +3937,7 @@ int btrfs_balance(struct btrfs_balance_control *bctl,
if ((ret && ret != -ECANCELED && ret != -ENOSPC) ||
balance_need_close(fs_info)) {
__cancel_balance(fs_info);
clear_bit(BTRFS_FS_EXCL_OP, &fs_info->flags);
}

wake_up(&fs_info->balance_wait_q);
Expand All @@ -3947,10 +3946,10 @@ int btrfs_balance(struct btrfs_balance_control *bctl,
out:
if (bctl->flags & BTRFS_BALANCE_RESUME)
__cancel_balance(fs_info);
else {
else
kfree(bctl);
clear_bit(BTRFS_FS_EXCL_OP, &fs_info->flags);
}
clear_bit(BTRFS_FS_EXCL_OP, &fs_info->flags);

return ret;
}

Expand Down Expand Up @@ -4118,8 +4117,10 @@ int btrfs_cancel_balance(struct btrfs_fs_info *fs_info)
mutex_lock(&fs_info->volume_mutex);
mutex_lock(&fs_info->balance_mutex);

if (fs_info->balance_ctl)
if (fs_info->balance_ctl) {
__cancel_balance(fs_info);
clear_bit(BTRFS_FS_EXCL_OP, &fs_info->flags);
}

mutex_unlock(&fs_info->volume_mutex);
}
Expand Down

0 comments on commit a17c95d

Please sign in to comment.