btrfs: tree-checker: Replace root parameter with fs_info
PATCH 1/1 btrfs: tree-checker: Replace root parameter with fs_info
When inspecting the error message with real corruption, the "root=%llu" always shows "1" (root tree), instead of correct owner.
The problem is that we are getting @root from page->mapping->host, which points the same btree inode, so we will always get the same root.
This makes the root owner output meaningless, and harder to port tree-checker to btrfs-progs.
So get rid of the false and meaningless @root parameter and replace it with @fs_info.
To get the owner, we can only rely on btrfs_header_owner() now.
--- fs/btrfs/disk-io.c | 6 +- fs/btrfs/tree-checker.c | 149 +++++++++++++++++++++++++----------------------- fs/btrfs/tree-checker.h | 7 ++- 3 files changed, 84 insertions(+), 78 deletions(-)
fs/btrfs/disk-io.c +3 -3
@@ -601,12 +601,12 @@ static int btree_readpage_end_io_hook(struct btrfs_io_bio *io_bio,* that we don't try and read the other copies of this block, just * return -EIO. */ -if (found_level ==0 &&btrfs_check_leaf_full (root, eb)) { +if (found_level ==0 &&btrfs_check_leaf_full (fs_info, eb)) {set_bit (EXTENT_BUFFER_CORRUPT , &eb->bflags); ret = -EIO ; } -if (found_level >0 &&btrfs_check_node (root, eb)) +if (found_level >0 &&btrfs_check_node (fs_info, eb)) ret = -EIO ;if (!ret)
@@ -3849,7 +3849,7 @@ void btrfs_mark_buffer_dirty(struct extent_buffer *buf)* So here we should only check item pointers, not item data. */ if (btrfs_header_level (buf) ==0 && -btrfs_check_leaf_relaxed (root, buf)) { +btrfs_check_leaf_relaxed (fs_info, buf)) {btrfs_print_leaf (buf);ASSERT (0 ); }
fs/btrfs/tree-checker.c +77 -72
420 lines not on this page · raw message
fs/btrfs/tree-checker.h +4 -3
@@ -25,14 +25,15 @@* Will check not only the item pointers, but also every possible member * in item data. */ -int btrfs_check_leaf_full (struct btrfs_root *root,struct extent_buffer *leaf); +int btrfs_check_leaf_full (struct btrfs_fs_info *fs_info, +struct extent_buffer *leaf);/* * Less strict leaf checker. * Will only check item pointers, not reading item data. */ -int btrfs_check_leaf_relaxed (struct btrfs_root *root, +int btrfs_check_leaf_relaxed (struct btrfs_fs_info *fs_info,struct extent_buffer *leaf); -int btrfs_check_node (struct btrfs_root *root,struct extent_buffer *node); +int btrfs_check_node (struct btrfs_fs_info *fs_info,struct extent_buffer *node);#endif
Signature · 1 line
2.15.1
Quoted 6 lines · Qu Wenruo
When inspecting the error message with real corruption, the "root=%llu" always shows "1" (root tree), instead of correct owner.
The problem is that we are getting @root from
page->mapping->host, which points the same btree inode, so we will always get the same root.
Quoted 8 lines
This makes the root owner output meaningless, and harder to port tree-checker to btrfs-progs.
So get rid of the false and meaningless @root parameter and replace it with @fs_info.
To get the owner, we can only rely onbtrfs_header_owner()now.Signed-off-by Qu Wenruo <[email protected]>
Thanks,
Josef
Quoted 10 lines · Josef Bacik
Quoted 9 lines · Qu Wenruo
When inspecting the error message with real corruption, the "root=%llu" always shows "1" (root tree), instead of correct owner.
The problem is that we are getting @root from
page->mapping->host, which points the same btree inode, so we will always get the same root.This makes the root owner output meaningless, and harder to port tree-checker to btrfs-progs.
Quoted 7 lines
Quoted 5 lines
So get rid of the false and meaningless @root parameter and replace it with @fs_info.
To get the owner, we can only rely onbtrfs_header_owner()now.Signed-off-by Qu Wenruo <[email protected]>Reviewed-by Josef Bacik <[email protected]>
Added to next, thanks.