mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-05 01:54:09 +08:00
btrfs: qgroup: remove duplicated check in adding qgroup relations
Removes duplicated check when adding qgroup relations. btrfs_add_qgroup_relations function adds relations by calling add_relation_rb(). add_relation_rb() checks that member/parentid exists in current qgroup_tree. But it already checked before calling the function. It seems that we don't need to double check. Add new function __add_relation_rb() that adds relations with qgroup structures and makes old function use the new one. And it makes btrfs_add_qgroup_relation() function work without double checks by calling the new function. Signed-off-by: Sidong Yang <realwakka@gmail.com> Reviewed-by: David Sterba <dsterba@suse.com> [ add comments ] Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
dc4a4bdb3f
commit
a8f6f619e4
@ -258,16 +258,19 @@ static int del_qgroup_rb(struct btrfs_fs_info *fs_info, u64 qgroupid)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* must be called with qgroup_lock held */
|
||||
static int add_relation_rb(struct btrfs_fs_info *fs_info,
|
||||
u64 memberid, u64 parentid)
|
||||
/*
|
||||
* Add relation specified by two qgroups.
|
||||
*
|
||||
* Must be called with qgroup_lock held.
|
||||
*
|
||||
* Return: 0 on success
|
||||
* -ENOENT if one of the qgroups is NULL
|
||||
* <0 other errors
|
||||
*/
|
||||
static int __add_relation_rb(struct btrfs_qgroup *member, struct btrfs_qgroup *parent)
|
||||
{
|
||||
struct btrfs_qgroup *member;
|
||||
struct btrfs_qgroup *parent;
|
||||
struct btrfs_qgroup_list *list;
|
||||
|
||||
member = find_qgroup_rb(fs_info, memberid);
|
||||
parent = find_qgroup_rb(fs_info, parentid);
|
||||
if (!member || !parent)
|
||||
return -ENOENT;
|
||||
|
||||
@ -283,7 +286,27 @@ static int add_relation_rb(struct btrfs_fs_info *fs_info,
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* must be called with qgroup_lock held */
|
||||
/*
|
||||
* Add relation specified by two qgoup ids.
|
||||
*
|
||||
* Must be called with qgroup_lock held.
|
||||
*
|
||||
* Return: 0 on success
|
||||
* -ENOENT if one of the ids does not exist
|
||||
* <0 other errors
|
||||
*/
|
||||
static int add_relation_rb(struct btrfs_fs_info *fs_info, u64 memberid, u64 parentid)
|
||||
{
|
||||
struct btrfs_qgroup *member;
|
||||
struct btrfs_qgroup *parent;
|
||||
|
||||
member = find_qgroup_rb(fs_info, memberid);
|
||||
parent = find_qgroup_rb(fs_info, parentid);
|
||||
|
||||
return __add_relation_rb(member, parent);
|
||||
}
|
||||
|
||||
/* Must be called with qgroup_lock held */
|
||||
static int del_relation_rb(struct btrfs_fs_info *fs_info,
|
||||
u64 memberid, u64 parentid)
|
||||
{
|
||||
@ -1457,7 +1480,7 @@ int btrfs_add_qgroup_relation(struct btrfs_trans_handle *trans, u64 src,
|
||||
}
|
||||
|
||||
spin_lock(&fs_info->qgroup_lock);
|
||||
ret = add_relation_rb(fs_info, src, dst);
|
||||
ret = __add_relation_rb(member, parent);
|
||||
if (ret < 0) {
|
||||
spin_unlock(&fs_info->qgroup_lock);
|
||||
goto out;
|
||||
|
Loading…
Reference in New Issue
Block a user