From patchwork Thu Aug 9 04:10:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Misono Tomohiro X-Patchwork-Id: 10560867 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9074513BB for ; Thu, 9 Aug 2018 04:11:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 72A0A2AA94 for ; Thu, 9 Aug 2018 04:11:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 673182AAD6; Thu, 9 Aug 2018 04:11:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EF97C2AAC2 for ; Thu, 9 Aug 2018 04:11:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727570AbeHIGde (ORCPT ); Thu, 9 Aug 2018 02:33:34 -0400 Received: from mgwkm04.jp.fujitsu.com ([202.219.69.171]:41092 "EHLO mgwkm04.jp.fujitsu.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726926AbeHIGde (ORCPT ); Thu, 9 Aug 2018 02:33:34 -0400 Received: from kw-mxauth.gw.nic.fujitsu.com (unknown [192.168.231.132]) by mgwkm04.jp.fujitsu.com with smtp id 649f_4b2b_491b0a6d_47b8_4724_aa96_982570c57f6c; Thu, 09 Aug 2018 13:10:40 +0900 Received: from g01jpfmpwkw03.exch.g01.fujitsu.local (g01jpfmpwkw03.exch.g01.fujitsu.local [10.0.193.57]) by kw-mxauth.gw.nic.fujitsu.com (Postfix) with ESMTP id 02C1DAC01A2 for ; Thu, 9 Aug 2018 13:10:38 +0900 (JST) Received: from G01JPEXCHKW15.g01.fujitsu.local (G01JPEXCHKW15.g01.fujitsu.local [10.0.194.54]) by g01jpfmpwkw03.exch.g01.fujitsu.local (Postfix) with ESMTP id 34898BD67EA for ; Thu, 9 Aug 2018 13:10:36 +0900 (JST) X-SecurityPolicyCheck: OK by SHieldMailChecker v2.5.2 X-SHieldMailCheckerPolicyVersion: FJ-ISEC-20170217-enc X-SHieldMailCheckerMailID: 2e92063631d74650bb061913dac3cdfa From: Misono Tomohiro Subject: [PATCH] btrfs: qgroup: Always remove all qgroup relation in btrfs_remove_qgroup() References: To: linux-btrfs Message-ID: <3efcb82a-5fcb-4d20-1ab9-5d03bbc6b999@jp.fujitsu.com> Date: Thu, 9 Aug 2018 13:10:33 +0900 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US X-SecurityPolicyCheck-GC: OK by FENCE-Mail X-TM-AS-MML: disable Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In btrfs_remove_qgroup(), each qgroup relation is removed by calling __del_qgroup_relation(). However, __del_qgroup_relation() returns 1 if deletion of qgroup relation causes inconsistency and current code exits immediately in that case. Therefore if there are several qgroup relations and removing first relation causes inconsistency, remaining items will not be removed. Fix this by continuing to remove items if return value of __del_qgroup_relation() is 1. Signed-off-by: Misono Tomohiro Reviewed-by: Qu Wenruo --- fs/btrfs/qgroup.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c index 2ba29f0609d9..f18284253e77 100644 --- a/fs/btrfs/qgroup.c +++ b/fs/btrfs/qgroup.c @@ -1428,12 +1428,21 @@ int btrfs_remove_qgroup(struct btrfs_trans_handle *trans, u64 qgroupid) goto out; while (!list_empty(&qgroup->groups)) { + int ret2; + list = list_first_entry(&qgroup->groups, struct btrfs_qgroup_list, next_group); - ret = __del_qgroup_relation(trans, qgroupid, + ret2 = __del_qgroup_relation(trans, qgroupid, list->group->qgroupid); - if (ret) - goto out; + if (ret2) { + ret = ret2; + /* + * __del_qgroup_relation() returns 1 if qgroup becomes + * inconsistent. Continue to remove items in that case. + */ + if (ret != 1) + goto out; + } } spin_lock(&fs_info->qgroup_lock);