From patchwork Thu Jul 17 19:39:04 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Fasheh X-Patchwork-Id: 4578491 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 82FA29F1D6 for ; Thu, 17 Jul 2014 19:40:42 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id ACB57201BB for ; Thu, 17 Jul 2014 19:40:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B856D201BA for ; Thu, 17 Jul 2014 19:40:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754833AbaGQTke (ORCPT ); Thu, 17 Jul 2014 15:40:34 -0400 Received: from cantor2.suse.de ([195.135.220.15]:52286 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754637AbaGQTkc (ORCPT ); Thu, 17 Jul 2014 15:40:32 -0400 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 40226ABA6; Thu, 17 Jul 2014 19:40:31 +0000 (UTC) From: Mark Fasheh To: linux-btrfs@vger.kernel.org Cc: Chris Mason , Josef Bacik , Mark Fasheh Subject: [PATCH 5/5] btrfs: correctly handle return from ulist_add Date: Thu, 17 Jul 2014 12:39:04 -0700 Message-Id: <1405625944-4883-6-git-send-email-mfasheh@suse.de> X-Mailer: git-send-email 1.8.4.5 In-Reply-To: <1405625944-4883-1-git-send-email-mfasheh@suse.de> References: <1405625944-4883-1-git-send-email-mfasheh@suse.de> Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- fs/btrfs/qgroup.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c index 2ec2432..b55870c 100644 --- a/fs/btrfs/qgroup.c +++ b/fs/btrfs/qgroup.c @@ -1976,6 +1976,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 = {}; @@ -2030,10 +2031,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); @@ -2045,10 +2048,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; + } } }