Commit 25152cb7 authored by Qu Wenruo's avatar Qu Wenruo Committed by David Sterba

btrfs: qgroup: use qgroup_iterator in btrfs_qgroup_free_refroot()

With the new qgroup_iterator_add() and qgroup_iterator_clean(), we can
get rid of the ulist and its GFP_ATOMIC memory allocation.
Reviewed-by: default avatarBoris Burkov <boris@bur.io>
Signed-off-by: default avatarQu Wenruo <wqu@suse.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 686c4a5a
...@@ -3204,9 +3204,7 @@ void btrfs_qgroup_free_refroot(struct btrfs_fs_info *fs_info, ...@@ -3204,9 +3204,7 @@ void btrfs_qgroup_free_refroot(struct btrfs_fs_info *fs_info,
enum btrfs_qgroup_rsv_type type) enum btrfs_qgroup_rsv_type type)
{ {
struct btrfs_qgroup *qgroup; struct btrfs_qgroup *qgroup;
struct ulist_node *unode; LIST_HEAD(qgroup_list);
struct ulist_iterator uiter;
int ret = 0;
if (!is_fstree(ref_root)) if (!is_fstree(ref_root))
return; return;
...@@ -3234,30 +3232,17 @@ void btrfs_qgroup_free_refroot(struct btrfs_fs_info *fs_info, ...@@ -3234,30 +3232,17 @@ void btrfs_qgroup_free_refroot(struct btrfs_fs_info *fs_info,
*/ */
num_bytes = qgroup->rsv.values[type]; num_bytes = qgroup->rsv.values[type];
ulist_reinit(fs_info->qgroup_ulist); qgroup_iterator_add(&qgroup_list, qgroup);
ret = ulist_add(fs_info->qgroup_ulist, qgroup->qgroupid, list_for_each_entry(qgroup, &qgroup_list, iterator) {
qgroup_to_aux(qgroup), GFP_ATOMIC);
if (ret < 0)
goto out;
ULIST_ITER_INIT(&uiter);
while ((unode = ulist_next(fs_info->qgroup_ulist, &uiter))) {
struct btrfs_qgroup *qg;
struct btrfs_qgroup_list *glist; struct btrfs_qgroup_list *glist;
qg = unode_aux_to_qgroup(unode); qgroup_rsv_release(fs_info, qgroup, num_bytes, type);
list_for_each_entry(glist, &qgroup->groups, next_group) {
qgroup_rsv_release(fs_info, qg, num_bytes, type); qgroup_iterator_add(&qgroup_list, glist->group);
list_for_each_entry(glist, &qg->groups, next_group) {
ret = ulist_add(fs_info->qgroup_ulist,
glist->group->qgroupid,
qgroup_to_aux(glist->group), GFP_ATOMIC);
if (ret < 0)
goto out;
} }
} }
out: out:
qgroup_iterator_clean(&qgroup_list);
spin_unlock(&fs_info->qgroup_lock); spin_unlock(&fs_info->qgroup_lock);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment