From patchwork Mon Jan 4 01:01:34 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Byongho Lee X-Patchwork-Id: 7944631 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 15D01BEEED for ; Mon, 4 Jan 2016 01:02:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3621F20384 for ; Mon, 4 Jan 2016 01:02:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4B1272038D for ; Mon, 4 Jan 2016 01:02:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752498AbcADBCq (ORCPT ); Sun, 3 Jan 2016 20:02:46 -0500 Received: from mail-pa0-f42.google.com ([209.85.220.42]:36743 "EHLO mail-pa0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752185AbcADBCO (ORCPT ); Sun, 3 Jan 2016 20:02:14 -0500 Received: by mail-pa0-f42.google.com with SMTP id yy13so95967693pab.3 for ; Sun, 03 Jan 2016 17:02:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id:in-reply-to:references; bh=J4bj+VQLjuVx35REU7djppu63CY0rPt5y9G+v2ETVf4=; b=uG7CsJ4JeP5c1sj7zHa2LvdyR8lJWLQk39LjATvuPVJm75v3z/i1fLDBdyDw1ad9q4 3SlLsRBXGlv5Rce7SkDziUsxM5VI8IQrrjMxg/oaLh40GbsLpaZ1Y8cKNB1FsbLuPXMb DM7n+/KqcpddQmP+kVZQlzhVXO90sfJzlzEYrcAITw2lnzGQlVqgxSmWr7dgoqQgr0jV nWZRyLbUSiaPdGNkq/9KgsOCVRkqpRts5RN7ha2LN2XTmB33qIAjUyWpXXVueWa9+yGi upFO3SKtO2J8hcW2P8LrdWtiSm0BH+jgdg5a/61QZrOrGHE3QDQIw5S3+fcfTp7vbDe8 eqsA== X-Received: by 10.67.3.170 with SMTP id bx10mr89165516pad.34.1451869334330; Sun, 03 Jan 2016 17:02:14 -0800 (PST) Received: from arch-gct.localdomain ([175.114.213.172]) by smtp.gmail.com with ESMTPSA id 184sm45125786pfa.15.2016.01.03.17.02.12 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 03 Jan 2016 17:02:13 -0800 (PST) From: Byongho Lee To: linux-btrfs@vger.kernel.org Subject: [PATCH v2 6/6] btrfs-progs: fix using on-disk structure to store in memory data Date: Mon, 4 Jan 2016 10:01:34 +0900 Message-Id: <1451869294-4291-7-git-send-email-bhlee.kernel@gmail.com> X-Mailer: git-send-email 2.6.4 In-Reply-To: <1451869294-4291-1-git-send-email-bhlee.kernel@gmail.com> References: <1451869294-4291-1-git-send-email-bhlee.kernel@gmail.com> Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In 'qgroup_count' structure 'diskinfo' and 'info' are used to store only in memory data but its types are for on-disk structure as a result sparse warns it (different base types). So fix it by adding new structure 'qgroup_info' to store in memory data and replace on-disk structure 'btrfs_qgroup_info_item' by 'qgroup_info'. In addition in alloc_cnt() 'generation' is set but not used after that so remove the relevant code. Signed-off-by: Byongho Lee --- v2: remove, "Signed-off-by: Zach Brown " which was for below patch but added by mistake. '[PATCH 4/6] btrfs-progs: fix endian bugs in chunk rebuilding' --- qgroup-verify.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/qgroup-verify.c b/qgroup-verify.c index 0ee52ff5c857..a0a4d4a5f5d9 100644 --- a/qgroup-verify.c +++ b/qgroup-verify.c @@ -37,16 +37,23 @@ static unsigned long tot_extents_scanned = 0; static void add_bytes(u64 root_objectid, u64 num_bytes, int exclusive); +struct qgroup_info { + u64 referenced; + u64 referenced_compressed; + u64 exclusive; + u64 exclusive_compressed; +}; + struct qgroup_count { - u64 qgroupid; - int subvol_exists; + u64 qgroupid; + int subvol_exists; - struct btrfs_disk_key key; - struct btrfs_qgroup_info_item diskinfo; + struct btrfs_disk_key key; + struct qgroup_info diskinfo; - struct btrfs_qgroup_info_item info; + struct qgroup_info info; - struct rb_node rb_node; + struct rb_node rb_node; }; static struct counts_tree { @@ -647,14 +654,13 @@ static struct qgroup_count *alloc_count(struct btrfs_disk_key *key, struct btrfs_qgroup_info_item *disk) { struct qgroup_count *c = calloc(1, sizeof(*c)); - struct btrfs_qgroup_info_item *item; + struct qgroup_info *item; if (c) { c->qgroupid = btrfs_disk_key_offset(key); c->key = *key; item = &c->diskinfo; - item->generation = btrfs_qgroup_info_generation(leaf, disk); item->referenced = btrfs_qgroup_info_referenced(leaf, disk); item->referenced_compressed = btrfs_qgroup_info_referenced_compressed(leaf, disk); @@ -673,7 +679,7 @@ static struct qgroup_count *alloc_count(struct btrfs_disk_key *key, static void add_bytes(u64 root_objectid, u64 num_bytes, int exclusive) { struct qgroup_count *count = find_count(root_objectid); - struct btrfs_qgroup_info_item *qg; + struct qgroup_info *qg; BUG_ON(num_bytes < 4096); /* Random sanity check. */ @@ -1014,8 +1020,8 @@ static void print_fields_signed(long long bytes, static void print_qgroup_difference(struct qgroup_count *count, int verbose) { int is_different; - struct btrfs_qgroup_info_item *info = &count->info; - struct btrfs_qgroup_info_item *disk = &count->diskinfo; + struct qgroup_info *info = &count->info; + struct qgroup_info *disk = &count->diskinfo; long long excl_diff = info->exclusive - disk->exclusive; long long ref_diff = info->referenced - disk->referenced;