Commit 193f284d authored by Chris Mason's avatar Chris Mason

Btrfs: ratelimit IO error printks

Btrfs has printks for various IO errors, including bad checksums and
mismatches between what we expect the block headers to contain and what
we actually find on the disk.

Longer term we need a real reporting mechanism for this, but for now
printk is going to have to do.
Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
parent b7967db7
...@@ -232,10 +232,14 @@ static int csum_tree_block(struct btrfs_root *root, struct extent_buffer *buf, ...@@ -232,10 +232,14 @@ static int csum_tree_block(struct btrfs_root *root, struct extent_buffer *buf,
memcpy(&found, result, csum_size); memcpy(&found, result, csum_size);
read_extent_buffer(buf, &val, 0, csum_size); read_extent_buffer(buf, &val, 0, csum_size);
printk(KERN_INFO "btrfs: %s checksum verify failed " if (printk_ratelimit()) {
"on %llu wanted %X found %X level %d\n", printk(KERN_INFO "btrfs: %s checksum verify "
"failed on %llu wanted %X found %X "
"level %d\n",
root->fs_info->sb->s_id, root->fs_info->sb->s_id,
buf->start, val, found, btrfs_header_level(buf)); (unsigned long long)buf->start, val, found,
btrfs_header_level(buf));
}
if (result != (char *)&inline_result) if (result != (char *)&inline_result)
kfree(result); kfree(result);
return 1; return 1;
...@@ -268,10 +272,13 @@ static int verify_parent_transid(struct extent_io_tree *io_tree, ...@@ -268,10 +272,13 @@ static int verify_parent_transid(struct extent_io_tree *io_tree,
ret = 0; ret = 0;
goto out; goto out;
} }
printk("parent transid verify failed on %llu wanted %llu found %llu\n", if (printk_ratelimit()) {
printk("parent transid verify failed on %llu wanted %llu "
"found %llu\n",
(unsigned long long)eb->start, (unsigned long long)eb->start,
(unsigned long long)parent_transid, (unsigned long long)parent_transid,
(unsigned long long)btrfs_header_generation(eb)); (unsigned long long)btrfs_header_generation(eb));
}
ret = 1; ret = 1;
clear_extent_buffer_uptodate(io_tree, eb); clear_extent_buffer_uptodate(io_tree, eb);
out: out:
...@@ -415,9 +422,12 @@ static int btree_readpage_end_io_hook(struct page *page, u64 start, u64 end, ...@@ -415,9 +422,12 @@ static int btree_readpage_end_io_hook(struct page *page, u64 start, u64 end,
found_start = btrfs_header_bytenr(eb); found_start = btrfs_header_bytenr(eb);
if (found_start != start) { if (found_start != start) {
printk(KERN_INFO "btrfs bad tree block start %llu %llu\n", if (printk_ratelimit()) {
printk(KERN_INFO "btrfs bad tree block start "
"%llu %llu\n",
(unsigned long long)found_start, (unsigned long long)found_start,
(unsigned long long)eb->start); (unsigned long long)eb->start);
}
ret = -EIO; ret = -EIO;
goto err; goto err;
} }
...@@ -429,8 +439,10 @@ static int btree_readpage_end_io_hook(struct page *page, u64 start, u64 end, ...@@ -429,8 +439,10 @@ static int btree_readpage_end_io_hook(struct page *page, u64 start, u64 end,
goto err; goto err;
} }
if (check_tree_block_fsid(root, eb)) { if (check_tree_block_fsid(root, eb)) {
if (printk_ratelimit()) {
printk(KERN_INFO "btrfs bad fsid on block %llu\n", printk(KERN_INFO "btrfs bad fsid on block %llu\n",
(unsigned long long)eb->start); (unsigned long long)eb->start);
}
ret = -EIO; ret = -EIO;
goto err; goto err;
} }
......
...@@ -1823,10 +1823,12 @@ static int btrfs_readpage_end_io_hook(struct page *page, u64 start, u64 end, ...@@ -1823,10 +1823,12 @@ static int btrfs_readpage_end_io_hook(struct page *page, u64 start, u64 end,
return 0; return 0;
zeroit: zeroit:
if (printk_ratelimit()) {
printk(KERN_INFO "btrfs csum failed ino %lu off %llu csum %u " printk(KERN_INFO "btrfs csum failed ino %lu off %llu csum %u "
"private %llu\n", page->mapping->host->i_ino, "private %llu\n", page->mapping->host->i_ino,
(unsigned long long)start, csum, (unsigned long long)start, csum,
(unsigned long long)private); (unsigned long long)private);
}
memset(kaddr + offset, 1, end - start + 1); memset(kaddr + offset, 1, end - start + 1);
flush_dcache_page(page); flush_dcache_page(page);
kunmap_atomic(kaddr, KM_USER0); kunmap_atomic(kaddr, KM_USER0);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment