* [PATCH 0/2] btrfs-progs: Fix qgroup false alerts on uninitialized rescan
@ 2018-07-26 6:38 Qu Wenruo
2018-07-26 6:39 ` [PATCH 1/2] btrfs-progs: qgroup-verify: Don't treat qgroup difference as error if the fs hasn't initialized a rescan Qu Wenruo
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Qu Wenruo @ 2018-07-26 6:38 UTC (permalink / raw)
To: linux-btrfs
This patches can be fetched from github:
https://github.com/adam900710/btrfs-progs/tree/qgroup_report
It's possible that certain timed power loss could lead to initialized quota
tree without rescan kicked in.
Can be reproduced in btrfs/166 with low possibility.
In that case, since default flags for QUOTA_STATUS is ON|INCONSISTENT,
btrfs check will still check qgroups and report difference as error.
However rescan progress of QUOTA_STATUS is still 0, means qgroup rescan
hasn't been kicked in, and all quota numbers are 0, difference is
expected.
In this case, make btrfs check don't report such uninitialized rescan as
error.
Qu Wenruo (2):
btrfs-progs: qgroup-verify: Don't treat qgroup difference as error if
the fs hasn't initialized a rescan
btrfs-progs: fsck-tests: Add test image to check if btrfs check
reports uninitialized rescan as error
qgroup-verify.c | 14 +++++++++++++-
.../no_rescan_kicked_in.img | Bin 0 -> 3072 bytes
.../fsck-tests/035-rescan-not-kicked-in/test.sh | 16 ++++++++++++++++
3 files changed, 29 insertions(+), 1 deletion(-)
create mode 100644 tests/fsck-tests/035-rescan-not-kicked-in/no_rescan_kicked_in.img
create mode 100755 tests/fsck-tests/035-rescan-not-kicked-in/test.sh
--
2.18.0
^ permalink raw reply [flat|nested] 4+ messages in thread* [PATCH 1/2] btrfs-progs: qgroup-verify: Don't treat qgroup difference as error if the fs hasn't initialized a rescan 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 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 2 siblings, 0 replies; 4+ messages in thread From: Qu Wenruo @ 2018-07-26 6:39 UTC (permalink / raw) To: linux-btrfs 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 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] btrfs-progs: fsck-tests: Add test image to check if btrfs check reports uninitialized rescan as error 2018-07-26 6:38 [PATCH 0/2] btrfs-progs: Fix qgroup false alerts on uninitialized rescan Qu Wenruo 2018-07-26 6:39 ` [PATCH 1/2] btrfs-progs: qgroup-verify: Don't treat qgroup difference as error if the fs hasn't initialized a rescan Qu Wenruo @ 2018-07-26 6:39 ` Qu Wenruo 2018-08-03 14:58 ` [PATCH 0/2] btrfs-progs: Fix qgroup false alerts on uninitialized rescan David Sterba 2 siblings, 0 replies; 4+ messages in thread From: Qu Wenruo @ 2018-07-26 6:39 UTC (permalink / raw) To: linux-btrfs Signed-off-by: Qu Wenruo <wqu@suse.com> --- .../no_rescan_kicked_in.img | Bin 0 -> 3072 bytes .../fsck-tests/035-rescan-not-kicked-in/test.sh | 16 ++++++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 tests/fsck-tests/035-rescan-not-kicked-in/no_rescan_kicked_in.img create mode 100755 tests/fsck-tests/035-rescan-not-kicked-in/test.sh diff --git a/tests/fsck-tests/035-rescan-not-kicked-in/no_rescan_kicked_in.img b/tests/fsck-tests/035-rescan-not-kicked-in/no_rescan_kicked_in.img new file mode 100644 index 0000000000000000000000000000000000000000..b855a72ff1dd7f629472450a67c27202fb21c628 GIT binary patch literal 3072 zcmeH|c~H|y7RP}gS6DemA_6*I;EoUxSPpR{VU$B+B9|!VAaWy-pb$<A2GBv}X26Jm zFo1{#f(Zl&0a;XxFvuZ<5E71voFN<nIrt4wTP5ZGzg1i1tFG>EzwUbV>eF5CrTXTC zjU92Li2cVT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sh b/tests/fsck-tests/035-rescan-not-kicked-in/test.sh new file mode 100755 index 000000000000..7d632653332f --- /dev/null +++ b/tests/fsck-tests/035-rescan-not-kicked-in/test.sh @@ -0,0 +1,16 @@ +#!/bin/bash +# Under certain power loss case, btrfs quota tree can be initialized but +# rescan not kicked in. (can be reproduced in low possibility in btrfs/166). +# +# This test case is to ensure for such special case, btrfs check doesn't report +# such qgroup difference as error, thus no false alert for btrfs/166. + +source "$TEST_TOP/common" + +check_prereq btrfs + +check_image() { + run_check "$TOP/btrfs" check "$1" +} + +check_all_images -- 2.18.0 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 0/2] btrfs-progs: Fix qgroup false alerts on uninitialized rescan 2018-07-26 6:38 [PATCH 0/2] btrfs-progs: Fix qgroup false alerts on uninitialized rescan Qu Wenruo 2018-07-26 6:39 ` [PATCH 1/2] btrfs-progs: qgroup-verify: Don't treat qgroup difference as error if the fs hasn't initialized a rescan Qu Wenruo 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 ` David Sterba 2 siblings, 0 replies; 4+ messages in thread From: David Sterba @ 2018-08-03 14:58 UTC (permalink / raw) To: Qu Wenruo; +Cc: linux-btrfs On Thu, Jul 26, 2018 at 02:38:59PM +0800, Qu Wenruo wrote: > This patches can be fetched from github: > https://github.com/adam900710/btrfs-progs/tree/qgroup_report > > It's possible that certain timed power loss could lead to initialized quota > tree without rescan kicked in. > Can be reproduced in btrfs/166 with low possibility. > > In that case, since default flags for QUOTA_STATUS is ON|INCONSISTENT, > btrfs check will still check qgroups and report difference as error. > > However rescan progress of QUOTA_STATUS is still 0, means qgroup rescan > hasn't been kicked in, and all quota numbers are 0, difference is > expected. > > In this case, make btrfs check don't report such uninitialized rescan as > error. > > Qu Wenruo (2): > btrfs-progs: qgroup-verify: Don't treat qgroup difference as error if > the fs hasn't initialized a rescan > btrfs-progs: fsck-tests: Add test image to check if btrfs check > reports uninitialized rescan as error Applied, thanks. ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-08-03 16:55 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2018-07-26 6:38 [PATCH 0/2] btrfs-progs: Fix qgroup false alerts on uninitialized rescan Qu Wenruo 2018-07-26 6:39 ` [PATCH 1/2] btrfs-progs: qgroup-verify: Don't treat qgroup difference as error if the fs hasn't initialized a rescan Qu Wenruo 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
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).