btrfs-progs: check: Output verbose error when fsck found a bug in any tree

Although we output error like "errors found in extent allocation tree or
chunk allocation", but we lacks such output for other trees, but leaving
the final "found error is %d" to catch the last return value(and
sometime it's cleared)

This patch adds extra error message for top level error path, and modify
the last "found error is %d" to "error(s) found" or "no error found".

Cc: Christoph Anton Mitterer <calestyo@scientia.net>
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
Qu Wenruo 2017-02-21 16:34:28 +08:00 committed by David Sterba
parent dd4c7680db
commit 18b668d6d5
1 changed files with 33 additions and 10 deletions

View File

@ -12912,8 +12912,10 @@ int cmd_check(int argc, char **argv)
ret = repair_root_items(info);
err |= !!ret;
if (ret < 0)
if (ret < 0) {
error("failed to repair root items: %s", strerror(-ret));
goto close_out;
}
if (repair) {
fprintf(stderr, "Fixed %d roots.\n", ret);
ret = 0;
@ -12936,8 +12938,13 @@ int cmd_check(int argc, char **argv)
}
ret = check_space_cache(root);
err |= !!ret;
if (ret)
if (ret) {
if (btrfs_fs_compat_ro(info, FREE_SPACE_TREE))
error("errors found in free space tree");
else
error("errors found in free space cache");
goto out;
}
/*
* We used to have to have these hole extents in between our real
@ -12953,23 +12960,29 @@ int cmd_check(int argc, char **argv)
else
ret = check_fs_roots(root, &root_cache);
err |= !!ret;
if (ret)
if (ret) {
error("errors found in fs roots");
goto out;
}
fprintf(stderr, "checking csums\n");
ret = check_csums(root);
err |= !!ret;
if (ret)
if (ret) {
error("errors found in csum tree");
goto out;
}
fprintf(stderr, "checking root refs\n");
/* For low memory mode, check_fs_roots_v2 handles root refs */
if (check_mode != CHECK_MODE_LOWMEM) {
ret = check_root_refs(root, &root_cache);
err |= !!ret;
if (ret)
if (ret) {
error("errors found in root refs");
goto out;
}
}
while (repair && !list_empty(&root->fs_info->recow_ebs)) {
struct extent_buffer *eb;
@ -12979,9 +12992,11 @@ int cmd_check(int argc, char **argv)
list_del_init(&eb->recow);
ret = recow_extent_buffer(root, eb);
err |= !!ret;
if (ret)
if (ret) {
error("fails to fix transid errors");
break;
}
}
while (!list_empty(&delete_items)) {
struct bad_item *bad;
@ -12999,13 +13014,17 @@ int cmd_check(int argc, char **argv)
fprintf(stderr, "checking quota groups\n");
ret = qgroup_verify_all(info);
err |= !!ret;
if (ret)
if (ret) {
error("failed to check quota groups");
goto out;
}
report_qgroups(0);
ret = repair_qgroups(info, &qgroups_repaired);
err |= !!ret;
if (err)
if (err) {
error("failed to repair quota groups");
goto out;
}
ret = 0;
}
@ -13026,8 +13045,12 @@ out:
"backup data and re-format the FS. *\n\n");
err |= 1;
}
printf("found %llu bytes used err is %d\n",
(unsigned long long)bytes_used, ret);
printf("found %llu bytes used, ",
(unsigned long long)bytes_used);
if (err)
printf("error(s) found\n");
else
printf("no error found\n");
printf("total csum bytes: %llu\n",(unsigned long long)total_csum_bytes);
printf("total tree bytes: %llu\n",
(unsigned long long)total_btree_bytes);