Skip to content

Commit

Permalink
btrfs: correctly handle return from ulist_add
Browse files Browse the repository at this point in the history
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: Mark Fasheh <mfasheh@suse.de>
Signed-off-by: Chris Mason <clm@fb.com>
  • Loading branch information
Mark Fasheh authored and Chris Mason committed Aug 15, 2014
1 parent 1152651 commit f90e579
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions fs/btrfs/qgroup.c
Original file line number Diff line number Diff line change
Expand Up @@ -1959,6 +1959,7 @@ static int qgroup_subtree_accounting(struct btrfs_trans_handle *trans,
struct btrfs_qgroup_list *glist;
struct ulist *parents;
int ret = 0;
int err;
struct btrfs_qgroup *qg;
u64 root_obj = 0;
struct seq_list elem = {};
Expand Down Expand Up @@ -2013,10 +2014,12 @@ static int qgroup_subtree_accounting(struct btrfs_trans_handle *trans,
* while adding parents of the parents to our ulist.
*/
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);
if (ret < 0)
if (err < 0) {
ret = err;
goto out_unlock;
}
}

ULIST_ITER_INIT(&uiter);
Expand All @@ -2028,10 +2031,12 @@ static int qgroup_subtree_accounting(struct btrfs_trans_handle *trans,

/* Add any parents of the parents */
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);
if (ret < 0)
if (err < 0) {
ret = err;
goto out_unlock;
}
}
}

Expand Down

0 comments on commit f90e579

Please sign in to comment.