diff mbox series

[v2] btrfs: output extra debug info if we failed to find an inline backref

Message ID a27590a76d9682dadd39379c23ab7cbb00062833.1690887719.git.wqu@suse.com (mailing list archive)
State New, archived
Headers show
Series [v2] btrfs: output extra debug info if we failed to find an inline backref | expand

Commit Message

Qu Wenruo Aug. 1, 2023, 11:02 a.m. UTC
[BUG]
Syzbot reported several warning triggered inside
lookup_inline_extent_backref().

[CAUSE]
As usual, the reproducer doesn't reliably trigger locally here, but at
least we know the WARN_ON() is triggered when an inline backref can not
be found, and it can only be triggered when @insert is true. (aka,
inserting a new inline backref, which means the backref should already
exist)

[ENHANCEMENT]
After the WARN_ON(), dump all the parameter and the extent tree
leaf to help debug.

Link: https://syzkaller.appspot.com/bug?extid=d6f9ff86c1d804ba2bc6
Signed-off-by: Qu Wenruo <wqu@suse.com>
---
Changelog:
v2:
- Follow the common error message pattern to put the error messages last
- Go back to the existing WARN_ON() checks
---
 fs/btrfs/extent-tree.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

David Sterba Aug. 10, 2023, 5:25 p.m. UTC | #1
On Tue, Aug 01, 2023 at 07:02:28PM +0800, Qu Wenruo wrote:
> [BUG]
> Syzbot reported several warning triggered inside
> lookup_inline_extent_backref().
> 
> [CAUSE]
> As usual, the reproducer doesn't reliably trigger locally here, but at
> least we know the WARN_ON() is triggered when an inline backref can not
> be found, and it can only be triggered when @insert is true. (aka,
> inserting a new inline backref, which means the backref should already
> exist)
> 
> [ENHANCEMENT]
> After the WARN_ON(), dump all the parameter and the extent tree
> leaf to help debug.
> 
> Link: https://syzkaller.appspot.com/bug?extid=d6f9ff86c1d804ba2bc6
> Signed-off-by: Qu Wenruo <wqu@suse.com>
> ---
> Changelog:
> v2:
> - Follow the common error message pattern to put the error messages last
> - Go back to the existing WARN_ON() checks

Added to misc-next, thanks.
diff mbox series

Patch

diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 3cae798499e2..c4564bdd3274 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -848,6 +848,11 @@  int lookup_inline_extent_backref(struct btrfs_trans_handle *trans,
 		err = -ENOENT;
 		goto out;
 	} else if (WARN_ON(ret)) {
+		btrfs_print_leaf(path->nodes[0]);
+		btrfs_err(fs_info,
+"extent item not found for insert, bytenr %llu num_bytes %llu parent %llu root_objectid %llu owner %llu offset %llu",
+			  bytenr, num_bytes, parent, root_objectid, owner,
+			  offset);
 		err = -EIO;
 		goto out;
 	}