From: Qu Wenruo <wqu@suse.com>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH 1/2] btrfs-progs: qgroup-verify: Don't treat qgroup difference as error if the fs hasn't initialized a rescan
Date: Thu, 26 Jul 2018 14:39:00 +0800 [thread overview]
Message-ID: <20180726063901.1252-2-wqu@suse.com> (raw)
In-Reply-To: <20180726063901.1252-1-wqu@suse.com>
During test btrfs/166, it's possible to hit a certain case where qgroup
is just enabled but rescan hasn't been kicked in.
Since at qgroup enable time, we mark INCONSISTENT flag, and let later
rescan to clear that flag, if power loss before we kick in rescan, it's
possible we get a qgroup status item with ON|INCONSISTENT but without
RESCAN flag.
And in that case, it will definitely cause difference in qgroup numbers
(as all numbers in qgroup tree is 0).
Fix this false alert by also checking rescan progress from
btrfs_status_item.
And if we find rescan progress is still 0, INCONSISTENT flag set and no
RESCAN flag set, we won't treat it as an error.
Reported-by: Lu Fengqi <lufq.fnst@cn.fujitsu.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>
---
qgroup-verify.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/qgroup-verify.c b/qgroup-verify.c
index e2332be2975a..21db79d5cf7d 100644
--- a/qgroup-verify.c
+++ b/qgroup-verify.c
@@ -77,6 +77,7 @@ static struct counts_tree {
unsigned int num_groups;
unsigned int rescan_running:1;
unsigned int qgroup_inconsist:1;
+ u64 scan_progress;
} counts = { .root = RB_ROOT };
static LIST_HEAD(bad_qgroups);
@@ -914,6 +915,7 @@ static void read_qgroup_status(struct extent_buffer *eb, int slot,
counts->qgroup_inconsist = !!(flags &
BTRFS_QGROUP_STATUS_FLAG_INCONSISTENT);
counts->rescan_running = !!(flags & BTRFS_QGROUP_STATUS_FLAG_RESCAN);
+ counts->scan_progress = btrfs_qgroup_status_rescan(eb, status_item);
}
static int load_quota_info(struct btrfs_fs_info *info)
@@ -1311,6 +1313,7 @@ int report_qgroups(int all)
struct rb_node *node;
struct qgroup_count *c;
bool found_err = false;
+ bool skip_err = false;
if (!repair && counts.rescan_running) {
if (all) {
@@ -1322,6 +1325,15 @@ int report_qgroups(int all)
return 0;
}
}
+ /*
+ * It's possible that rescan hasn't been initialized yet.
+ */
+ if (counts.qgroup_inconsist && !counts.rescan_running &&
+ counts.rescan_running == 0) {
+ printf(
+"Rescan hasn't been initialzied, a difference in qgroup counts is expected\n");
+ skip_err = true;
+ }
if (counts.qgroup_inconsist && !counts.rescan_running)
fprintf(stderr, "Qgroup are marked as inconsistent.\n");
node = rb_first(&counts.root);
@@ -1335,7 +1347,7 @@ int report_qgroups(int all)
node = rb_next(node);
}
- if (found_err)
+ if (found_err && !skip_err)
return -EUCLEAN;
return 0;
}
--
2.18.0
next prev parent reply other threads:[~2018-07-26 7:54 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-26 6:38 [PATCH 0/2] btrfs-progs: Fix qgroup false alerts on uninitialized rescan Qu Wenruo
2018-07-26 6:39 ` Qu Wenruo [this message]
2018-07-26 6:39 ` [PATCH 2/2] btrfs-progs: fsck-tests: Add test image to check if btrfs check reports uninitialized rescan as error Qu Wenruo
2018-08-03 14:58 ` [PATCH 0/2] btrfs-progs: Fix qgroup false alerts on uninitialized rescan 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=20180726063901.1252-2-wqu@suse.com \
--to=wqu@suse.com \
--cc=linux-btrfs@vger.kernel.org \
/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).