Commit f90e579c authored by Mark Fasheh's avatar Mark Fasheh Committed by Chris Mason

btrfs: correctly handle return from ulist_add

ulist_add() can return '1' on sucess, which qgroup_subtree_accounting()
doesn't take into account. As a result, that value can be bubbled up to
callers, causing an error to be printed. Fix this by only returning the
value of ulist_add() when it indicates an error.
Signed-off-by: default avatarMark Fasheh <mfasheh@suse.de>
Signed-off-by: default avatarChris Mason <clm@fb.com>
parent 1152651a
...@@ -1959,6 +1959,7 @@ static int qgroup_subtree_accounting(struct btrfs_trans_handle *trans, ...@@ -1959,6 +1959,7 @@ static int qgroup_subtree_accounting(struct btrfs_trans_handle *trans,
struct btrfs_qgroup_list *glist; struct btrfs_qgroup_list *glist;
struct ulist *parents; struct ulist *parents;
int ret = 0; int ret = 0;
int err;
struct btrfs_qgroup *qg; struct btrfs_qgroup *qg;
u64 root_obj = 0; u64 root_obj = 0;
struct seq_list elem = {}; struct seq_list elem = {};
...@@ -2013,11 +2014,13 @@ static int qgroup_subtree_accounting(struct btrfs_trans_handle *trans, ...@@ -2013,11 +2014,13 @@ static int qgroup_subtree_accounting(struct btrfs_trans_handle *trans,
* while adding parents of the parents to our ulist. * while adding parents of the parents to our ulist.
*/ */
list_for_each_entry(glist, &qg->groups, next_group) { list_for_each_entry(glist, &qg->groups, next_group) {
ret = ulist_add(parents, glist->group->qgroupid, err = ulist_add(parents, glist->group->qgroupid,
ptr_to_u64(glist->group), GFP_ATOMIC); ptr_to_u64(glist->group), GFP_ATOMIC);
if (ret < 0) if (err < 0) {
ret = err;
goto out_unlock; goto out_unlock;
} }
}
ULIST_ITER_INIT(&uiter); ULIST_ITER_INIT(&uiter);
while ((unode = ulist_next(parents, &uiter))) { while ((unode = ulist_next(parents, &uiter))) {
...@@ -2028,12 +2031,14 @@ static int qgroup_subtree_accounting(struct btrfs_trans_handle *trans, ...@@ -2028,12 +2031,14 @@ static int qgroup_subtree_accounting(struct btrfs_trans_handle *trans,
/* Add any parents of the parents */ /* Add any parents of the parents */
list_for_each_entry(glist, &qg->groups, next_group) { list_for_each_entry(glist, &qg->groups, next_group) {
ret = ulist_add(parents, glist->group->qgroupid, err = ulist_add(parents, glist->group->qgroupid,
ptr_to_u64(glist->group), GFP_ATOMIC); ptr_to_u64(glist->group), GFP_ATOMIC);
if (ret < 0) if (err < 0) {
ret = err;
goto out_unlock; goto out_unlock;
} }
} }
}
out_unlock: out_unlock:
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