From: Qu Wenruo <quwenruo@cn.fujitsu.com>
To: linux-btrfs@vger.kernel.org, mfasheh@suse.de
Subject: [PATCH 3/3] btrfs-progs: Read qgroup status for qgroup verify
Date: Mon, 18 Apr 2016 10:27:09 +0800 [thread overview]
Message-ID: <1460946429-578-3-git-send-email-quwenruo@cn.fujitsu.com> (raw)
In-Reply-To: <1460946429-578-1-git-send-email-quwenruo@cn.fujitsu.com>
Read qgroup status for its flags like QGROUP_STATUS_FLAG_RESCAN and
QGROUP_STATUS_FLAG_INCONSISTENT.
This will help to avoid false alert for case like qgroup rescan is still
running when un-mounted.
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
---
qgroup-verify.c | 33 +++++++++++++++++++++++++++++++--
1 file changed, 31 insertions(+), 2 deletions(-)
diff --git a/qgroup-verify.c b/qgroup-verify.c
index 48e4d22..e2b8be3 100644
--- a/qgroup-verify.c
+++ b/qgroup-verify.c
@@ -59,6 +59,8 @@ struct qgroup_count {
static struct counts_tree {
struct rb_root root;
unsigned int num_groups;
+ unsigned int rescan_running:1;
+ unsigned int qgroup_inconsist:1;
} counts = { .root = RB_ROOT };
static struct rb_root by_bytenr = RB_ROOT;
@@ -700,6 +702,19 @@ static void add_bytes(u64 root_objectid, u64 num_bytes, int exclusive)
}
}
+static void read_qgroup_status(struct btrfs_path *path,
+ 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);
+ 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)
{
int ret;
@@ -734,13 +749,17 @@ static int load_quota_info(struct btrfs_fs_info *info)
btrfs_item_key(leaf, &disk_key, i);
btrfs_disk_key_to_cpu(&key, &disk_key);
+ if (key.type == BTRFS_QGROUP_STATUS_KEY) {
+ read_qgroup_status(&path, &counts);
+ continue;
+ }
if (key.type == BTRFS_QGROUP_RELATION_KEY)
printf("Ignoring qgroup relation key %llu\n",
key.objectid);
/*
- * Ignore: BTRFS_QGROUP_STATUS_KEY,
- * BTRFS_QGROUP_LIMIT_KEY, BTRFS_QGROUP_RELATION_KEY
+ * Ignore: BTRFS_QGROUP_LIMIT_KEY,
+ * BTRFS_QGROUP_RELATION_KEY
*/
if (key.type != BTRFS_QGROUP_INFO_KEY)
continue;
@@ -1055,6 +1074,16 @@ int report_qgroups(int all)
struct qgroup_count *c;
int ret = 0;
+ if (counts.rescan_running) {
+ if (all)
+ printf("Qgroup rescan is running, qgroup counts difference is expected\n");
+ else {
+ printf("Qgroup rescan is running, ignore qgroup check\n");
+ return ret;
+ }
+ }
+ if (counts.qgroup_inconsist && !counts.rescan_running)
+ fprintf(stderr, "Qgroup is already inconsistent before checking\n");
node = rb_first(&counts.root);
while (node) {
c = rb_entry(node, struct qgroup_count, rb_node);
--
2.8.0
next prev parent reply other threads:[~2016-04-18 2:29 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-18 2:27 [PATCH 1/3] btrfs-progs: Fix return value bug of qgroups check Qu Wenruo
2016-04-18 2:27 ` [PATCH 2/3] btrfs-progs: Fix an extent buffer leak in " Qu Wenruo
2016-04-18 2:27 ` Qu Wenruo [this message]
2016-04-25 12:09 ` [PATCH 1/3] btrfs-progs: Fix return value bug of " David Sterba
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=1460946429-578-3-git-send-email-quwenruo@cn.fujitsu.com \
--to=quwenruo@cn.fujitsu.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=mfasheh@suse.de \
/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).