From patchwork Mon May 7 08:50:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lu Fengqi X-Patchwork-Id: 10383675 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 F301060353 for ; Mon, 7 May 2018 08:50:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E741128B7E for ; Mon, 7 May 2018 08:50:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DB6A528B91; Mon, 7 May 2018 08:50:41 +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 54E8728B7E for ; Mon, 7 May 2018 08:50:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752307AbeEGIuj (ORCPT ); Mon, 7 May 2018 04:50:39 -0400 Received: from mail.cn.fujitsu.com ([183.91.158.132]:18537 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752265AbeEGIuh (ORCPT ); Mon, 7 May 2018 04:50:37 -0400 X-IronPort-AV: E=Sophos;i="5.43,368,1503331200"; d="scan'208";a="39636135" Received: from localhost (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 07 May 2018 16:50:34 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (unknown [10.167.33.80]) by cn.fujitsu.com (Postfix) with ESMTP id 2F3624B34D23 for ; Mon, 7 May 2018 16:50:36 +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; Mon, 7 May 2018 16:50:37 +0800 From: Lu Fengqi To: Subject: [PATCH] btrfs-progs: qgroup: swap the argument in the caller of update_qgroup_relation Date: Mon, 7 May 2018 16:50:27 +0800 Message-ID: <20180507085027.23059-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: 2F3624B34D23.A9B2F 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 --- qgroup.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/qgroup.c b/qgroup.c index 11659e8394dd..e7e127daf5ce 100644 --- a/qgroup.c +++ b/qgroup.c @@ -1122,11 +1122,16 @@ static int __qgroups_search(int fd, struct qgroup_lookup *qgroup_lookup) qgroupid = btrfs_search_header_offset(sh); qgroupid1 = btrfs_search_header_objectid(sh); - if (qgroupid < qgroupid1) + if (qgroupid <= qgroupid1) break; + /* + * because of qgroupid > qgroupid1, qgroupid is + * the id of parent, and qgroupid1 is the id of + * child. + */ ret = update_qgroup_relation(qgroup_lookup, - qgroupid, qgroupid1); + qgroupid1, qgroupid); break; default: return ret;