From patchwork Wed Sep 7 02:54:19 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qu Wenruo X-Patchwork-Id: 9318145 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 AF27660760 for ; Wed, 7 Sep 2016 02:59:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9A0E728FA0 for ; Wed, 7 Sep 2016 02:59:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8CF7028FA4; Wed, 7 Sep 2016 02:59:16 +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=-6.9 required=2.0 tests=BAYES_00,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 0097728FA0 for ; Wed, 7 Sep 2016 02:59:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934248AbcIGCy2 (ORCPT ); Tue, 6 Sep 2016 22:54:28 -0400 Received: from cn.fujitsu.com ([59.151.112.132]:21890 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S933598AbcIGCy1 (ORCPT ); Tue, 6 Sep 2016 22:54:27 -0400 X-IronPort-AV: E=Sophos;i="5.22,518,1449504000"; d="scan'208";a="10689454" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 07 Sep 2016 10:54:23 +0800 Received: from G08CNEXCHPEKD02.g08.fujitsu.local (unknown [10.167.33.83]) by cn.fujitsu.com (Postfix) with ESMTP id 38E554042401; Wed, 7 Sep 2016 10:54:22 +0800 (CST) Received: from localhost.localdomain (10.167.226.34) by G08CNEXCHPEKD02.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.279.2; Wed, 7 Sep 2016 10:54:20 +0800 From: Qu Wenruo To: CC: Mark Fasheh Subject: [PATCH] btrfs-progs: qgroup: Fix regression leads to corrupted qgroup status Date: Wed, 7 Sep 2016 10:54:19 +0800 Message-ID: <20160907025419.23284-1-quwenruo@cn.fujitsu.com> X-Mailer: git-send-email 2.9.3 MIME-Version: 1.0 X-Originating-IP: [10.167.226.34] X-yoursite-MailScanner-ID: 38E554042401.AAEEC X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: quwenruo@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 Commit 93dabf211d74daf6e3de642bdd887a90a00f7b49 Author: Mark Fasheh Date: Fri Jun 17 13:37:48 2016 -0700 btrfs-progs: check: verify qgroups above level 0 This commit introduced a new regression which corrupts read_qgroup_status, since it iterate leaf with manually specified slot, not correct path->slot[0]. This leads to wrong slot[0] and read_qgroup_status() will read out wrong flags, leading to regression. Fix read_qgroup_status() by using eb and slot instread of wrong path strucutre. Reported-by: Tsutomu Itoh Cc: Mark Fasheh Signed-off-by: Qu Wenruo --- qgroup-verify.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/qgroup-verify.c b/qgroup-verify.c index 66eb870..f6df12d 100644 --- a/qgroup-verify.c +++ b/qgroup-verify.c @@ -874,15 +874,14 @@ static int add_qgroup_relation(u64 memberid, u64 parentid) return 0; } -static void read_qgroup_status(struct btrfs_path *path, +static void read_qgroup_status(struct extent_buffer *eb, int slot, struct counts_tree *counts) { struct btrfs_qgroup_status_item *status_item; u64 flags; - status_item = btrfs_item_ptr(path->nodes[0], path->slots[0], - struct btrfs_qgroup_status_item); - flags = btrfs_qgroup_status_flags(path->nodes[0], status_item); + status_item = btrfs_item_ptr(eb, slot, struct btrfs_qgroup_status_item); + flags = btrfs_qgroup_status_flags(eb, status_item); /* * Since qgroup_inconsist/rescan_running is just one bit, * assign value directly won't work. @@ -946,7 +945,7 @@ loop: } if (key.type == BTRFS_QGROUP_STATUS_KEY) { - read_qgroup_status(&path, &counts); + read_qgroup_status(leaf, i, &counts); continue; }