Blob Blame History Raw
From 7f72f50547b7af4ddf985b07fc56600a4deba281 Mon Sep 17 00:00:00 2001
Message-ID: <7f72f50547b7af4ddf985b07fc56600a4deba281.1694126558.git.wqu@suse.com>
From: Qu Wenruo <wqu@suse.com>
Date: Tue, 1 Aug 2023 19:02:28 +0800
Patch-mainline: v6.6-rc1
References: bsc#1215136
Git-commit: 7f72f50547b7af4ddf985b07fc56600a4deba281
Subject: [PATCH] btrfs: output extra debug info if we failed to find an inline
 backref

[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. (I.e.
inserting a new inline backref, which means the backref should already
exist)

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

Link: https://syzkaller.appspot.com/bug?extid=d6f9ff86c1d804ba2bc6
Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
[ Rebased to handle the older btrfs_print_leaf() definition ]
---
 fs/btrfs/extent-tree.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index e0508114f0bd..105f528382e7 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(fs_info, 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;
 	}
-- 
2.42.0