No functional changed. Just simplify the code.
Signed-off-by: ChenXiaoSong <[email protected]>
---
fs/btrfs/qgroup.c | 34 +++++++++++++++++-----------------
1 file changed, 17 insertions(+), 17 deletions(-)
diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c
index d0480b9c6c86..ca609a70d067 100644
--- a/fs/btrfs/qgroup.c
+++ b/fs/btrfs/qgroup.c
@@ -1677,6 +1677,19 @@ int btrfs_remove_qgroup(struct btrfs_trans_handle *trans, u64 qgroupid)
return ret;
}
+static int btrfs_update_quoto_limit(struct btrfs_trans_handle *trans,
+ struct btrfs_qgroup *qgroup,
+ struct btrfs_fs_info *fs_info)
+{
+ int ret = update_qgroup_limit_item(trans, qgroup);
+ if (ret) {
+ qgroup_mark_inconsistent(fs_info);
+ btrfs_info(fs_info, "unable to update quota limit for %llu",
+ qgroup->qgroupid);
+ }
+ return ret;
+}
+
int btrfs_limit_qgroup(struct btrfs_trans_handle *trans, u64 qgroupid,
struct btrfs_qgroup_limit *limit)
{
@@ -1742,13 +1755,7 @@ int btrfs_limit_qgroup(struct btrfs_trans_handle *trans, u64 qgroupid,
spin_unlock(&fs_info->qgroup_lock);
- ret = update_qgroup_limit_item(trans, qgroup);
- if (ret) {
- qgroup_mark_inconsistent(fs_info);
- btrfs_info(fs_info, "unable to update quota limit for %llu",
- qgroupid);
- }
-
+ ret = btrfs_update_quoto_limit(trans, qgroup, fs_info);
out:
mutex_unlock(&fs_info->qgroup_ioctl_lock);
return ret;
@@ -2824,9 +2831,7 @@ int btrfs_run_qgroups(struct btrfs_trans_handle *trans)
ret = update_qgroup_info_item(trans, qgroup);
if (ret)
qgroup_mark_inconsistent(fs_info);
- ret = update_qgroup_limit_item(trans, qgroup);
- if (ret)
- qgroup_mark_inconsistent(fs_info);
+ ret = btrfs_update_quoto_limit(trans, qgroup, fs_info);
spin_lock(&fs_info->qgroup_lock);
}
if (test_bit(BTRFS_FS_QUOTA_ENABLED, &fs_info->flags))
@@ -2953,14 +2958,9 @@ int btrfs_qgroup_inherit(struct btrfs_trans_handle *trans, u64 srcid,
dstgroup->rsv_rfer = inherit->lim.rsv_rfer;
dstgroup->rsv_excl = inherit->lim.rsv_excl;
- ret = update_qgroup_limit_item(trans, dstgroup);
- if (ret) {
- qgroup_mark_inconsistent(fs_info);
- btrfs_info(fs_info,
- "unable to update quota limit for %llu",
- dstgroup->qgroupid);
+ ret = btrfs_update_quoto_limit(trans, dstgroup, fs_info);
+ if (ret)
goto unlock;
- }
}
if (srcid) {
--
2.31.1
On Wed, Nov 16, 2022 at 01:17:08AM +0800, ChenXiaoSong wrote:
> No functional changed. Just simplify the code.
Please write some description of the change, like "factor out quota
limit update that also marks qgroup as inconsistent if it fals".
> Signed-off-by: ChenXiaoSong <[email protected]>
> ---
> fs/btrfs/qgroup.c | 34 +++++++++++++++++-----------------
> 1 file changed, 17 insertions(+), 17 deletions(-)
>
> diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c
> index d0480b9c6c86..ca609a70d067 100644
> --- a/fs/btrfs/qgroup.c
> +++ b/fs/btrfs/qgroup.c
> @@ -1677,6 +1677,19 @@ int btrfs_remove_qgroup(struct btrfs_trans_handle *trans, u64 qgroupid)
> return ret;
> }
>
> +static int btrfs_update_quoto_limit(struct btrfs_trans_handle *trans,
Typo 'quoto' and it should rather be qgroup as the limit is related to a
qgroup, quota is usually in connection with the whole subsystem.
> + struct btrfs_qgroup *qgroup,
> + struct btrfs_fs_info *fs_info)
> +{
> + int ret = update_qgroup_limit_item(trans, qgroup);
> + if (ret) {
> + qgroup_mark_inconsistent(fs_info);
> + btrfs_info(fs_info, "unable to update quota limit for %llu",
> + qgroup->qgroupid);
> + }
> + return ret;
> +}
> +
> int btrfs_limit_qgroup(struct btrfs_trans_handle *trans, u64 qgroupid,
> struct btrfs_qgroup_limit *limit)
> {
> @@ -1742,13 +1755,7 @@ int btrfs_limit_qgroup(struct btrfs_trans_handle *trans, u64 qgroupid,
>
> spin_unlock(&fs_info->qgroup_lock);
>
> - ret = update_qgroup_limit_item(trans, qgroup);
> - if (ret) {
> - qgroup_mark_inconsistent(fs_info);
> - btrfs_info(fs_info, "unable to update quota limit for %llu",
> - qgroupid);
> - }
> -
> + ret = btrfs_update_quoto_limit(trans, qgroup, fs_info);
> out:
> mutex_unlock(&fs_info->qgroup_ioctl_lock);
> return ret;
> @@ -2824,9 +2831,7 @@ int btrfs_run_qgroups(struct btrfs_trans_handle *trans)
> ret = update_qgroup_info_item(trans, qgroup);
> if (ret)
> qgroup_mark_inconsistent(fs_info);
> - ret = update_qgroup_limit_item(trans, qgroup);
> - if (ret)
> - qgroup_mark_inconsistent(fs_info);
> + ret = btrfs_update_quoto_limit(trans, qgroup, fs_info);
> spin_lock(&fs_info->qgroup_lock);
> }
> if (test_bit(BTRFS_FS_QUOTA_ENABLED, &fs_info->flags))
> @@ -2953,14 +2958,9 @@ int btrfs_qgroup_inherit(struct btrfs_trans_handle *trans, u64 srcid,
> dstgroup->rsv_rfer = inherit->lim.rsv_rfer;
> dstgroup->rsv_excl = inherit->lim.rsv_excl;
>
> - ret = update_qgroup_limit_item(trans, dstgroup);
> - if (ret) {
> - qgroup_mark_inconsistent(fs_info);
> - btrfs_info(fs_info,
> - "unable to update quota limit for %llu",
> - dstgroup->qgroupid);
> + ret = btrfs_update_quoto_limit(trans, dstgroup, fs_info);
> + if (ret)
> goto unlock;
> - }
> }
>
> if (srcid) {
> --
> 2.31.1
>