Skip to content

Commit 85c9c42

Browse files
fdmananakdave
authored andcommitted
btrfs: qgroup: use btrfs_qgroup_enabled() in ioctls
We have a publicly exported btrfs_qgroup_enabled() and an ioctl.c private qgroup_enabled() helper. Both of these test if qgroups are enabled, the first check if the flag BTRFS_FS_QUOTA_ENABLED is set in fs_info->flags while the second checks if fs_info->quota_root is not NULL while holding the mutex fs_info->qgroup_ioctl_lock. We can get away with the private ioctl.c:qgroup_enabled(), as all entry points into the qgroup code check if fs_info->quota_root is NULL or not while holding the mutex fs_info->qgroup_ioctl_lock, and returning the error -ENOTCONN in case it's NULL. Reviewed-by: Qu Wenruo <wqu@suse.com> Signed-off-by: Filipe Manana <fdmanana@suse.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
1 parent b7bbc6e commit 85c9c42

File tree

1 file changed

+4
-20
lines changed

1 file changed

+4
-20
lines changed

fs/btrfs/ioctl.c

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3711,22 +3711,6 @@ static long btrfs_ioctl_quota_ctl(struct file *file, void __user *arg)
37113711
return ret;
37123712
}
37133713

3714-
/*
3715-
* Quick check for ioctl handlers if quotas are enabled. Proper locking must be
3716-
* done before any operations.
3717-
*/
3718-
static bool qgroup_enabled(struct btrfs_fs_info *fs_info)
3719-
{
3720-
bool ret = true;
3721-
3722-
mutex_lock(&fs_info->qgroup_ioctl_lock);
3723-
if (!fs_info->quota_root)
3724-
ret = false;
3725-
mutex_unlock(&fs_info->qgroup_ioctl_lock);
3726-
3727-
return ret;
3728-
}
3729-
37303714
static long btrfs_ioctl_qgroup_assign(struct file *file, void __user *arg)
37313715
{
37323716
struct inode *inode = file_inode(file);
@@ -3741,7 +3725,7 @@ static long btrfs_ioctl_qgroup_assign(struct file *file, void __user *arg)
37413725
if (!capable(CAP_SYS_ADMIN))
37423726
return -EPERM;
37433727

3744-
if (!qgroup_enabled(root->fs_info))
3728+
if (!btrfs_qgroup_enabled(fs_info))
37453729
return -ENOTCONN;
37463730

37473731
ret = mnt_want_write_file(file);
@@ -3811,7 +3795,7 @@ static long btrfs_ioctl_qgroup_create(struct file *file, void __user *arg)
38113795
if (!capable(CAP_SYS_ADMIN))
38123796
return -EPERM;
38133797

3814-
if (!qgroup_enabled(root->fs_info))
3798+
if (!btrfs_qgroup_enabled(root->fs_info))
38153799
return -ENOTCONN;
38163800

38173801
ret = mnt_want_write_file(file);
@@ -3870,7 +3854,7 @@ static long btrfs_ioctl_qgroup_limit(struct file *file, void __user *arg)
38703854
if (!capable(CAP_SYS_ADMIN))
38713855
return -EPERM;
38723856

3873-
if (!qgroup_enabled(root->fs_info))
3857+
if (!btrfs_qgroup_enabled(root->fs_info))
38743858
return -ENOTCONN;
38753859

38763860
ret = mnt_want_write_file(file);
@@ -3918,7 +3902,7 @@ static long btrfs_ioctl_quota_rescan(struct file *file, void __user *arg)
39183902
if (!capable(CAP_SYS_ADMIN))
39193903
return -EPERM;
39203904

3921-
if (!qgroup_enabled(fs_info))
3905+
if (!btrfs_qgroup_enabled(fs_info))
39223906
return -ENOTCONN;
39233907

39243908
ret = mnt_want_write_file(file);

0 commit comments

Comments
 (0)