From patchwork Thu Jun 16 01:15:51 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qu Wenruo X-Patchwork-Id: 9179737 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 64468604DB for ; Thu, 16 Jun 2016 01:16:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 55CA527DCE for ; Thu, 16 Jun 2016 01:16:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4A70C27D13; Thu, 16 Jun 2016 01:16:05 +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 C7EF327D13 for ; Thu, 16 Jun 2016 01:16:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933282AbcFPBQB (ORCPT ); Wed, 15 Jun 2016 21:16:01 -0400 Received: from cn.fujitsu.com ([222.73.24.84]:11603 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S933269AbcFPBQA (ORCPT ); Wed, 15 Jun 2016 21:16:00 -0400 X-IronPort-AV: E=Sophos;i="5.20,367,1444665600"; d="scan'208";a="634249" Received: from unknown (HELO cn.fujitsu.com) ([10.167.250.3]) by song.cn.fujitsu.com with ESMTP; 16 Jun 2016 09:15:53 +0800 Received: from adam-work.localdomain (unknown [10.167.226.34]) by cn.fujitsu.com (Postfix) with ESMTP id 875F54056404; Thu, 16 Jun 2016 09:15:52 +0800 (CST) From: Qu Wenruo To: dsterba@suse.cz, linux-btrfs@vger.kernel.org Subject: [PATCH] btrfs-progs: qgroup: Fix a bug that fails to skip rescan running case Date: Thu, 16 Jun 2016 09:15:51 +0800 Message-Id: <20160616011551.4356-1-quwenruo@cn.fujitsu.com> X-Mailer: git-send-email 2.8.3 MIME-Version: 1.0 X-yoursite-MailScanner-ID: 875F54056404.A9EEF 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 6bdf962fe35a8648d(btrfs-progs: Read qgroup status for qgroup verify) will read qgroup status, and then use it to skip qgroup reporting. However since the rescan_running/inconsistent flags are only 1 bit long, while qgroup flags & BTRFS_QGROUP_FLAGS returns value longer than 1bit, it doesn't work. Fix it by doing double negation on (flags & BTRFS_QGROUP_FLAGS) to convert it to either 1 or 0. Signed-off-by: Qu Wenruo --- qgroup-verify.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/qgroup-verify.c b/qgroup-verify.c index 1a0d38c..86dcd6d 100644 --- a/qgroup-verify.c +++ b/qgroup-verify.c @@ -711,8 +711,13 @@ static void read_qgroup_status(struct btrfs_path *path, 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); - counts->qgroup_inconsist = flags & BTRFS_QGROUP_STATUS_FLAG_INCONSISTENT; - counts->rescan_running = flags & BTRFS_QGROUP_STATUS_FLAG_RESCAN; + /* + * Since qgroup_inconsist/rescan_running is just one bit, + * assign value directly won't work. + */ + counts->qgroup_inconsist = !!(flags & + BTRFS_QGROUP_STATUS_FLAG_INCONSISTENT); + counts->rescan_running = !!(flags & BTRFS_QGROUP_STATUS_FLAG_RESCAN); } static int load_quota_info(struct btrfs_fs_info *info)