* [PATCH] btrfs-progs: check: Don't do early exit if maybe_repair_root_item() can't find needed root extent
@ 2020-04-29 10:10 Qu Wenruo
2020-05-11 18:46 ` David Sterba
0 siblings, 1 reply; 2+ messages in thread
From: Qu Wenruo @ 2020-04-29 10:10 UTC (permalink / raw)
To: linux-btrfs
The whole maybe_repair_root_item() and repair_root_items() functions are
introduced to handle an ancient bug in v3.17.
However in certain extent tree corruption case, such early exit would
only exit the whole check process early on, preventing user to know
what's really wrong about the fs.
So this patch will allow the check to continue, since the ancient bug is
no long that common.
Signed-off-by: Qu Wenruo <wqu@suse.com>
---
check/main.c | 32 ++++++++++++++++++++------------
1 file changed, 20 insertions(+), 12 deletions(-)
diff --git a/check/main.c b/check/main.c
index be980c152274..ac11a35125b8 100644
--- a/check/main.c
+++ b/check/main.c
@@ -10306,20 +10306,28 @@ static int cmd_check(const struct cmd_struct *cmd, int argc, char **argv)
err = !!ret;
errno = -ret;
error("failed to repair root items: %m");
- goto close_out;
- }
- if (repair) {
- fprintf(stderr, "Fixed %d roots.\n", ret);
- ret = 0;
- } else if (ret > 0) {
- fprintf(stderr,
+ /*
+ * For repair, if we can't repair root items, it's
+ * fatal.
+ * But for non-repair, it's pretty rare to hit such
+ * v3.17 era bug, we want to continue check.
+ */
+ if (repair)
+ goto close_out;
+ err |= 1;
+ } else {
+ if (repair) {
+ fprintf(stderr, "Fixed %d roots.\n", ret);
+ ret = 0;
+ } else if (ret > 0) {
+ fprintf(stderr,
"Found %d roots with an outdated root item.\n",
- ret);
- fprintf(stderr,
+ ret);
+ fprintf(stderr,
"Please run a filesystem check with the option --repair to fix them.\n");
- ret = 1;
- err |= ret;
- goto close_out;
+ ret = 1;
+ err |= ret;
+ }
}
} else {
fprintf(stderr, "[1/7] checking root items... skipped\n");
--
2.26.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] btrfs-progs: check: Don't do early exit if maybe_repair_root_item() can't find needed root extent
2020-04-29 10:10 [PATCH] btrfs-progs: check: Don't do early exit if maybe_repair_root_item() can't find needed root extent Qu Wenruo
@ 2020-05-11 18:46 ` David Sterba
0 siblings, 0 replies; 2+ messages in thread
From: David Sterba @ 2020-05-11 18:46 UTC (permalink / raw)
To: Qu Wenruo; +Cc: linux-btrfs
On Wed, Apr 29, 2020 at 06:10:15PM +0800, Qu Wenruo wrote:
> The whole maybe_repair_root_item() and repair_root_items() functions are
> introduced to handle an ancient bug in v3.17.
>
> However in certain extent tree corruption case, such early exit would
> only exit the whole check process early on, preventing user to know
> what's really wrong about the fs.
>
> So this patch will allow the check to continue, since the ancient bug is
> no long that common.
>
> Signed-off-by: Qu Wenruo <wqu@suse.com>
Added to devel, thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-05-11 18:47 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-04-29 10:10 [PATCH] btrfs-progs: check: Don't do early exit if maybe_repair_root_item() can't find needed root extent Qu Wenruo
2020-05-11 18:46 ` 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).