From patchwork Tue May 8 05:48:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lu Fengqi X-Patchwork-Id: 10385397 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B289C6037F for ; Tue, 8 May 2018 05:48:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 92C6328592 for ; Tue, 8 May 2018 05:48:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8748E285A8; Tue, 8 May 2018 05:48:22 +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 CE7AC28592 for ; Tue, 8 May 2018 05:48:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751876AbeEHFsT (ORCPT ); Tue, 8 May 2018 01:48:19 -0400 Received: from mail.cn.fujitsu.com ([183.91.158.132]:6052 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751289AbeEHFsT (ORCPT ); Tue, 8 May 2018 01:48:19 -0400 X-IronPort-AV: E=Sophos;i="5.43,368,1503331200"; d="scan'208";a="39676237" Received: from bogon (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 08 May 2018 13:48:13 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (unknown [10.167.33.80]) by cn.fujitsu.com (Postfix) with ESMTP id D737D4B314A2 for ; Tue, 8 May 2018 13:48:11 +0800 (CST) Received: from fnst.localdomain (10.167.226.155) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.361.1; Tue, 8 May 2018 13:48:13 +0800 From: Lu Fengqi To: Subject: [PATCH v2 1/2] btrfs-progs: qgroup: swap the argument in the caller of update_qgroup_relation Date: Tue, 8 May 2018 13:48:02 +0800 Message-ID: <20180508054803.20851-1-lufq.fnst@cn.fujitsu.com> X-Mailer: git-send-email 2.17.0 MIME-Version: 1.0 X-Originating-IP: [10.167.226.155] X-yoursite-MailScanner-ID: D737D4B314A2.AC865 X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: lufq.fnst@cn.fujitsu.com 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 The QGROUP_RELATION item is very special, it always exists in pairs (objectid and offset exchange). Its objectid and offset are the ids of a pair of parent and child qgroups, respectively. The larger one is parent and the smaller one is child. After the following commit, the order of the parameters is wrong and causes qgroup show to output the wrong qgroup parent-child relationship. Fixes: aaf2dac5ef37 ("btrfs-progs: qgroup: split update_qgroup to reduce arguments") Issue: #129 Signed-off-by: Lu Fengqi Reviewed-by: Qu Wenruo --- V2: Rename variables instead of the comment to make it clear. qgroup.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/qgroup.c b/qgroup.c index 11659e8394dd..267cd7f11a9c 100644 --- a/qgroup.c +++ b/qgroup.c @@ -1051,7 +1051,7 @@ static int __qgroups_search(int fd, struct qgroup_lookup *qgroup_lookup) struct btrfs_qgroup_limit_item *limit; u64 flags; u64 qgroupid; - u64 qgroupid1; + u64 child, parent; memset(&args, 0, sizeof(args)); @@ -1119,14 +1119,14 @@ static int __qgroups_search(int fd, struct qgroup_lookup *qgroup_lookup) qgroupid, limit); break; case BTRFS_QGROUP_RELATION_KEY: - qgroupid = btrfs_search_header_offset(sh); - qgroupid1 = btrfs_search_header_objectid(sh); + child = btrfs_search_header_offset(sh); + parent = btrfs_search_header_objectid(sh); - if (qgroupid < qgroupid1) + if (parent <= child) break; ret = update_qgroup_relation(qgroup_lookup, - qgroupid, qgroupid1); + child, parent); break; default: return ret;