Skip to content

Commit

Permalink
btrfs: qgroup: return ENOTCONN instead of EINVAL when quotas are not …
Browse files Browse the repository at this point in the history
…enabled

commit 8a36e40 upstream.

[PROBLEM]
qgroup create/remove code is currently returning EINVAL when the user
tries to create a qgroup on a subvolume without quota enabled. EINVAL is
already being used for too many error scenarios so that is hard to
depict what is the problem.

[FIX]
Currently scrub and balance code return -ENOTCONN when the user tries to
cancel/pause and no scrub or balance is currently running for the
desired subvolume. Do the same here by returning -ENOTCONN  when a user
tries to create/delete/assing/list a qgroup on a subvolume without quota
enabled.

Reviewed-by: Qu Wenruo <[email protected]>
Signed-off-by: Marcos Paulo de Souza <[email protected]>
Reviewed-by: David Sterba <[email protected]>
Signed-off-by: David Sterba <[email protected]>
Signed-off-by: Harshvardhan Jha <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
marcosps authored and gregkh committed Aug 11, 2023
1 parent 8c1d1f3 commit 4f8f86b
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions fs/btrfs/qgroup.c
Original file line number Diff line number Diff line change
Expand Up @@ -1411,7 +1411,7 @@ int btrfs_add_qgroup_relation(struct btrfs_trans_handle *trans, u64 src,

mutex_lock(&fs_info->qgroup_ioctl_lock);
if (!fs_info->quota_root) {
ret = -EINVAL;
ret = -ENOTCONN;
goto out;
}
member = find_qgroup_rb(fs_info, src);
Expand Down Expand Up @@ -1470,7 +1470,7 @@ static int __del_qgroup_relation(struct btrfs_trans_handle *trans, u64 src,
return -ENOMEM;

if (!fs_info->quota_root) {
ret = -EINVAL;
ret = -ENOTCONN;
goto out;
}

Expand Down Expand Up @@ -1536,7 +1536,7 @@ int btrfs_create_qgroup(struct btrfs_trans_handle *trans, u64 qgroupid)

mutex_lock(&fs_info->qgroup_ioctl_lock);
if (!fs_info->quota_root) {
ret = -EINVAL;
ret = -ENOTCONN;
goto out;
}
quota_root = fs_info->quota_root;
Expand Down Expand Up @@ -1570,7 +1570,7 @@ int btrfs_remove_qgroup(struct btrfs_trans_handle *trans, u64 qgroupid)

mutex_lock(&fs_info->qgroup_ioctl_lock);
if (!fs_info->quota_root) {
ret = -EINVAL;
ret = -ENOTCONN;
goto out;
}

Expand Down Expand Up @@ -1621,7 +1621,7 @@ int btrfs_limit_qgroup(struct btrfs_trans_handle *trans, u64 qgroupid,

mutex_lock(&fs_info->qgroup_ioctl_lock);
if (!fs_info->quota_root) {
ret = -EINVAL;
ret = -ENOTCONN;
goto out;
}

Expand Down

0 comments on commit 4f8f86b

Please sign in to comment.