linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Byongho Lee <bhlee.kernel@gmail.com>
To: linux-btrfs@vger.kernel.org
Cc: Zach Brown <zab@redhat.com>
Subject: [PATCH 6/6] btrfs-progs: fix using on-disk structure to store in memory data
Date: Mon,  4 Jan 2016 03:59:58 +0900	[thread overview]
Message-ID: <1451847598-30666-7-git-send-email-bhlee.kernel@gmail.com> (raw)
In-Reply-To: <1451847598-30666-1-git-send-email-bhlee.kernel@gmail.com>

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: Zach Brown <zab@redhat.com>
Signed-off-by: Byongho Lee <bhlee.kernel@gmail.com>
---
 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;
 
-- 
2.6.4


  parent reply	other threads:[~2016-01-03 19:00 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-03 18:59 [PATCH 0/6] fix endian bugs and clean-ups Byongho Lee
2016-01-03 18:59 ` [PATCH 1/6] btrfs-progs: get sparse checking working Byongho Lee
2016-01-03 18:59 ` [PATCH 2/6] btrfs-progs: use NULL instead of 0 Byongho Lee
2016-01-03 18:59 ` [PATCH 3/6] btrfs-progs: make private symbols to static Byongho Lee
2016-01-03 18:59 ` [PATCH 4/6] btrfs-progs: fix endian bugs in chunk rebuilding Byongho Lee
2016-01-03 18:59 ` [PATCH 5/6] btrfs-progs: fix endian bug in update_super() Byongho Lee
2016-01-03 18:59 ` Byongho Lee [this message]
2016-01-03 19:09 ` [PATCH 0/6] fix endian bugs and clean-ups Byongho Lee

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1451847598-30666-7-git-send-email-bhlee.kernel@gmail.com \
    --to=bhlee.kernel@gmail.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=zab@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).