u64 chunk_root_bytenr = 0;
char uuidbuf[BTRFS_UUID_UNPARSED_SIZE];
int ret;
+ int err = 0;
u64 num;
int init_csum_tree = 0;
int readonly = 0;
if((ret = check_mounted(argv[optind])) < 0) {
error("could not check mount status: %s", strerror(-ret));
+ err |= !!ret;
goto err_out;
} else if(ret) {
error("%s is currently mounted, aborting", argv[optind]);
ret = -EBUSY;
+ err |= !!ret;
goto err_out;
}
if (!info) {
error("cannot open file system");
ret = -EIO;
+ err |= !!ret;
goto err_out;
}
ret = ask_user("repair mode will force to clear out log tree, are you sure?");
if (!ret) {
ret = 1;
+ err |= !!ret;
goto close_out;
}
ret = zero_log_tree(root);
+ err |= !!ret;
if (ret) {
error("failed to zero log tree: %d", ret);
goto close_out;
printf("Print quota groups for %s\nUUID: %s\n", argv[optind],
uuidbuf);
ret = qgroup_verify_all(info);
+ err |= !!ret;
if (ret == 0)
report_qgroups(1);
goto close_out;
printf("Print extent state for subvolume %llu on %s\nUUID: %s\n",
subvolid, argv[optind], uuidbuf);
ret = print_extent_state(info, subvolid);
+ err |= !!ret;
goto close_out;
}
printf("Checking filesystem on %s\nUUID: %s\n", argv[optind], uuidbuf);
!extent_buffer_uptodate(info->dev_root->node) ||
!extent_buffer_uptodate(info->chunk_root->node)) {
error("critical roots corrupted, unable to check the filesystem");
+ err |= !!ret;
ret = -EIO;
goto close_out;
}
if (IS_ERR(trans)) {
error("error starting transaction");
ret = PTR_ERR(trans);
+ err |= !!ret;
goto close_out;
}
if (init_extent_tree) {
printf("Creating a new extent tree\n");
ret = reinit_extent_tree(trans, info);
+ err |= !!ret;
if (ret)
goto close_out;
}
error("checksum tree initialization failed: %d",
ret);
ret = -EIO;
+ err |= !!ret;
goto close_out;
}
ret = fill_csum_tree(trans, info->csum_root,
init_extent_tree);
+ err |= !!ret;
if (ret) {
error("checksum tree refilling failed: %d", ret);
return -EIO;
* extent entries for all of the items it finds.
*/
ret = btrfs_commit_transaction(trans, info->extent_root);
+ err |= !!ret;
if (ret)
goto close_out;
}
if (!extent_buffer_uptodate(info->extent_root->node)) {
error("critical: extent_root, unable to check the filesystem");
ret = -EIO;
+ err |= !!ret;
goto close_out;
}
if (!extent_buffer_uptodate(info->csum_root->node)) {
error("critical: csum_root, unable to check the filesystem");
ret = -EIO;
+ err |= !!ret;
goto close_out;
}
ret = check_chunks_and_extents_v2(root);
else
ret = check_chunks_and_extents(root);
+ err |= !!ret;
if (ret)
error(
"errors found in extent allocation tree or chunk allocation");
ret = repair_root_items(info);
+ err |= !!ret;
if (ret < 0)
goto close_out;
if (repair) {
fprintf(stderr,
"Please run a filesystem check with the option --repair to fix them.\n");
ret = 1;
+ err |= !!ret;
goto close_out;
}
fprintf(stderr, "checking free space cache\n");
}
ret = check_space_cache(root);
+ err |= !!ret;
if (ret)
goto out;
ret = check_fs_roots_v2(root->fs_info);
else
ret = check_fs_roots(root, &root_cache);
+ err |= !!ret;
if (ret)
goto out;
fprintf(stderr, "checking csums\n");
ret = check_csums(root);
+ err |= !!ret;
if (ret)
goto out;
/* 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)
goto out;
}
struct extent_buffer, recow);
list_del_init(&eb->recow);
ret = recow_extent_buffer(root, eb);
+ err |= !!ret;
if (ret)
break;
}
bad = list_first_entry(&delete_items, struct bad_item, list);
list_del_init(&bad->list);
- if (repair)
+ if (repair) {
ret = delete_bad_item(root, bad);
+ err |= !!ret;
+ }
free(bad);
}
if (info->quota_enabled) {
- int err;
fprintf(stderr, "checking quota groups\n");
- err = qgroup_verify_all(info);
- if (err)
+ ret = qgroup_verify_all(info);
+ err |= !!ret;
+ if (ret)
goto out;
report_qgroups(0);
- err = repair_qgroups(info, &qgroups_repaired);
+ ret = repair_qgroups(info, &qgroups_repaired);
+ err |= !!ret;
if (err)
goto out;
+ ret = 0;
}
if (!list_empty(&root->fs_info->recow_ebs)) {
error("transid errors in file system");
ret = 1;
+ err |= !!ret;
}
out:
- /* Don't override original ret */
- if (!ret && qgroups_repaired)
- ret = qgroups_repaired;
-
if (found_old_backref) { /*
* there was a disk format change when mixed
* backref was in testing tree. The old format
"The old format is not supported! *"
"\n * Please mount the FS in readonly mode, "
"backup data and re-format the FS. *\n\n");
- ret = 1;
+ err |= 1;
}
printf("found %llu bytes used err is %d\n",
(unsigned long long)bytes_used, ret);
if (ctx.progress_enabled)
task_deinit(ctx.info);
- return ret;
+ return err;
}