@@ -10423,20 +10423,24 @@ static int cmd_check(const struct cmd_struct *cmd, int argc, char **argv)
!extent_buffer_uptodate(gfs_info->dev_root->node) ||
!extent_buffer_uptodate(gfs_info->chunk_root->node)) {
error("critical roots corrupted, unable to check the filesystem");
- err |= !!ret;
ret = -EIO;
+ err |= !!ret;
goto close_out;
}
if (clear_space_cache) {
ret = do_clear_free_space_cache(clear_space_cache);
+ if (ret)
+ error("failed to clear free space cache");
err |= !!ret;
goto close_out;
}
if (clear_ino_cache) {
ret = clear_ino_cache_items();
- err = ret;
+ if (ret)
+ error("failed to clear inode cache");
+ err |= !!ret;
goto close_out;
}
@@ -10464,6 +10468,8 @@ static int cmd_check(const struct cmd_struct *cmd, int argc, char **argv)
uuidbuf);
ret = qgroup_verify_all(gfs_info);
err |= !!ret;
+ if (ret)
+ error("failed to verify all qgroup");
if (ret >= 0)
report_qgroups(1);
goto close_out;
@@ -10472,6 +10478,8 @@ static int cmd_check(const struct cmd_struct *cmd, int argc, char **argv)
printf("Print extent state for subvolume %llu on %s\nUUID: %s\n",
subvolid, argv[optind], uuidbuf);
ret = print_extent_state(gfs_info, subvolid);
+ if (ret)
+ error("failed to print extend state");
err |= !!ret;
goto close_out;
}
@@ -10493,8 +10501,10 @@ static int cmd_check(const struct cmd_struct *cmd, int argc, char **argv)
ret = reinit_extent_tree(trans,
check_mode == CHECK_MODE_ORIGINAL);
err |= !!ret;
- if (ret)
+ if (ret) {
+ error("failed to create a new extent tree");
goto close_out;
+ }
}
if (init_csum_tree) {
@@ -10522,8 +10532,10 @@ static int cmd_check(const struct cmd_struct *cmd, int argc, char **argv)
*/
ret = btrfs_commit_transaction(trans, gfs_info->extent_root);
err |= !!ret;
- if (ret)
+ if (ret) {
+ error("failed to commit btrfs transaction: %d", ret);
goto close_out;
+ }
}
if (!extent_buffer_uptodate(gfs_info->extent_root->node)) {
error("critical: extent_root, unable to check the filesystem");
@@ -10558,7 +10570,6 @@ static int cmd_check(const struct cmd_struct *cmd, int argc, char **argv)
*/
if (repair)
goto close_out;
- err |= 1;
} else {
if (repair) {
fprintf(stderr, "Fixed %d roots.\n", ret);
@@ -10591,7 +10602,10 @@ static int cmd_check(const struct cmd_struct *cmd, int argc, char **argv)
"errors found in extent allocation tree or chunk allocation");
/* Only re-check super size after we checked and repaired the fs */
- err |= !is_super_size_valid();
+ ret = !is_super_size_valid();
+ if (ret)
+ error("super size is not valid");
+ err |= !!ret;
is_free_space_tree = btrfs_fs_compat_ro(gfs_info, FREE_SPACE_TREE);
@@ -10607,6 +10621,8 @@ static int cmd_check(const struct cmd_struct *cmd, int argc, char **argv)
ret = validate_free_space_cache(root);
task_stop(ctx.info);
+ if (ret)
+ error("failed to validate free space cache");
err |= !!ret;
/*
@@ -10694,6 +10710,9 @@ static int cmd_check(const struct cmd_struct *cmd, int argc, char **argv)
list_del_init(&bad->list);
if (repair) {
ret = delete_bad_item(root, bad);
+ if (ret) {
+ error("failed to delete orphan items");
+ }
err |= !!ret;
}
free(bad);