Re: [PATCH] btrfs: tree-checker: Replace root parameter with fs_info

2018-01-30 Thread David Sterba
On Fri, Jan 26, 2018 at 09:31:06AM -0500, Josef Bacik wrote:
> On Thu, Jan 25, 2018 at 02:56:18PM +0800, Qu Wenruo wrote:
> > 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.
> > 
> > Signed-off-by: Qu Wenruo 
> 
> Reviewed-by: Josef Bacik 

Added to next, thanks.
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] btrfs: tree-checker: Replace root parameter with fs_info

2018-01-26 Thread Josef Bacik
On Thu, Jan 25, 2018 at 02:56:18PM +0800, Qu Wenruo wrote:
> 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.
> 
> Signed-off-by: Qu Wenruo 

Reviewed-by: Josef Bacik 

Thanks,

Josef
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] btrfs: tree-checker: Replace root parameter with fs_info

2018-01-24 Thread 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.

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.

Signed-off-by: Qu Wenruo 
---
 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(-)

diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index ed095202942f..b564038b858f 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -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, >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);
}
diff --git a/fs/btrfs/tree-checker.c b/fs/btrfs/tree-checker.c
index c3c8d48f6618..4ea44fa29a36 100644
--- a/fs/btrfs/tree-checker.c
+++ b/fs/btrfs/tree-checker.c
@@ -53,7 +53,7 @@
  * Allows callers to customize the output.
  */
 __printf(4, 5)
-static void generic_err(const struct btrfs_root *root,
+static void generic_err(const struct btrfs_fs_info *fs_info,
const struct extent_buffer *eb, int slot,
const char *fmt, ...)
 {
@@ -65,10 +65,10 @@ static void generic_err(const struct btrfs_root *root,
vaf.fmt = fmt;
vaf.va = 
 
-   btrfs_crit(root->fs_info,
+   btrfs_crit(fs_info,
"corrupt %s: root=%llu block=%llu slot=%d, %pV",
btrfs_header_level(eb) == 0 ? "leaf" : "node",
-   root->objectid, btrfs_header_bytenr(eb), slot, );
+   btrfs_header_owner(eb), btrfs_header_bytenr(eb), slot, );
va_end(args);
 }
 
@@ -77,7 +77,7 @@ static void generic_err(const struct btrfs_root *root,
  * offset has its own meaning.
  */
 __printf(4, 5)
-static void file_extent_err(const struct btrfs_root *root,
+static void file_extent_err(const struct btrfs_fs_info *fs_info,
const struct extent_buffer *eb, int slot,
const char *fmt, ...)
 {
@@ -91,10 +91,11 @@ static void file_extent_err(const struct btrfs_root *root,
vaf.fmt = fmt;
vaf.va = 
 
-   btrfs_crit(root->fs_info,
+   btrfs_crit(fs_info,
"corrupt %s: root=%llu block=%llu slot=%d ino=%llu file_offset=%llu, 
%pV",
-   btrfs_header_level(eb) == 0 ? "leaf" : "node", root->objectid,
-   btrfs_header_bytenr(eb), slot, key.objectid, key.offset, );
+   btrfs_header_level(eb) == 0 ? "leaf" : "node",
+   btrfs_header_owner(eb), btrfs_header_bytenr(eb), slot,
+   key.objectid, key.offset, );
va_end(args);
 }
 
@@ -102,26 +103,26 @@ static void file_extent_err(const struct btrfs_root *root,
  * Return 0 if the btrfs_file_extent_##name is aligned to @alignment
  * Else return 1
  */
-#define CHECK_FE_ALIGNED(root, leaf, slot, fi, name, alignment)
  \
+#define CHECK_FE_ALIGNED(fs_info, leaf, slot, fi, name, alignment)   \
 ({   \
if (!IS_ALIGNED(btrfs_file_extent_##name((leaf), (fi)), (alignment))) \
-   file_extent_err((root), (leaf), (slot),   \
+   file_extent_err((fs_info), (leaf), (slot),\
"invalid %s for file extent, have %llu, should be aligned to %u", \
(#name), btrfs_file_extent_##name((leaf), (fi)),  \
(alignment)); \
(!IS_ALIGNED(btrfs_file_extent_##name((leaf), (fi)), (alignment)));   \
 })
 
-static int check_extent_data_item(struct btrfs_root *root,
+static int check_extent_data_item(struct btrfs_fs_info *fs_info,