summaryrefslogtreecommitdiff
path: root/disk-io.c
diff options
context:
space:
mode:
authorQu Wenruo <quwenruo@cn.fujitsu.com>2015-01-16 11:04:09 +0800
committerDavid Sterba <dsterba@suse.cz>2015-02-11 17:14:05 +0100
commit0c05f623b13f93105163535f016fc049fa04dbb6 (patch)
treee2d1872b39f0500c697c6511591926fa4986d6b9 /disk-io.c
parent56e69234e471bb5982a4928da8e605d9d803b43a (diff)
downloadbtrfs-progs-0c05f623b13f93105163535f016fc049fa04dbb6.tar.gz
btrfs-progs: Add support to suppress tree block csum error output
Add new open ctree flag OPEN_CTREE_SUPPRESS_CHECK_BLOCK_ERRORS to suppress tree block csum error output. Provides the basis for new btrfs-find-root and other enhancement on btrfs offline tools output. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> [renamed vars and funcs, added comments] Signed-off-by: David Sterba <dsterba@suse.cz>
Diffstat (limited to 'disk-io.c')
-rw-r--r--disk-io.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/disk-io.c b/disk-io.c
index f418d4e..6c1961e 100644
--- a/disk-io.c
+++ b/disk-io.c
@@ -60,7 +60,7 @@ static int check_tree_block(struct btrfs_root *root, struct extent_buffer *buf)
return ret;
}
-static void print_tree_block_err(struct btrfs_root *root,
+static void print_tree_block_error(struct btrfs_root *root,
struct extent_buffer *eb,
int err)
{
@@ -141,6 +141,8 @@ int csum_tree_block(struct btrfs_root *root, struct extent_buffer *buf,
{
u16 csum_size =
btrfs_super_csum_size(root->fs_info->super_copy);
+ if (verify && root->fs_info->suppress_check_block_errors)
+ return verify_tree_block_csum_silent(buf, csum_size);
return csum_tree_block_size(buf, csum_size, verify);
}
@@ -291,8 +293,8 @@ struct extent_buffer *read_tree_block(struct btrfs_root *root, u64 bytenr,
while (1) {
ret = read_whole_eb(root->fs_info, eb, mirror_num);
- if (ret == 0 && check_tree_block(root, eb) == 0 &&
- csum_tree_block(root, eb, 1) == 0 &&
+ if (ret == 0 && csum_tree_block(root, eb, 1) == 0 &&
+ check_tree_block(root, eb) == 0 &&
verify_parent_transid(eb->tree, eb, parent_transid, ignore)
== 0) {
if (eb->flags & EXTENT_BAD_TRANSID &&
@@ -305,11 +307,14 @@ struct extent_buffer *read_tree_block(struct btrfs_root *root, u64 bytenr,
return eb;
}
if (ignore) {
- if (check_tree_block(root, eb))
- print_tree_block_err(root, eb,
+ if (check_tree_block(root, eb)) {
+ if (!root->fs_info->suppress_check_block_errors)
+ print_tree_block_error(root, eb,
check_tree_block(root, eb));
- else
- printk("Csum didn't match\n");
+ } else {
+ if (!root->fs_info->suppress_check_block_errors)
+ fprintf(stderr, "Csum didn't match\n");
+ }
ret = -EIO;
break;
}
@@ -371,7 +376,7 @@ static int write_tree_block(struct btrfs_trans_handle *trans,
struct extent_buffer *eb)
{
if (check_tree_block(root, eb)) {
- print_tree_block_err(root, eb, check_tree_block(root, eb));
+ print_tree_block_error(root, eb, check_tree_block(root, eb));
BUG();
}
@@ -1142,6 +1147,8 @@ static struct btrfs_fs_info *__open_ctree_fd(int fp, const char *path,
}
if (flags & OPEN_CTREE_RESTORE)
fs_info->on_restoring = 1;
+ if (flags & OPEN_CTREE_SUPPRESS_CHECK_BLOCK_ERRORS)
+ fs_info->suppress_check_block_errors = 1;
ret = btrfs_scan_fs_devices(fp, path, &fs_devices, sb_bytenr,
(flags & OPEN_CTREE_RECOVER_SUPER),