public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] btrfs: Improve error reporting in lookup_inline_extent_backref
@ 2022-04-20 11:54 Nikolay Borisov
  2022-04-20 14:52 ` David Sterba
                   ` (5 more replies)
  0 siblings, 6 replies; 9+ messages in thread
From: Nikolay Borisov @ 2022-04-20 11:54 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Nikolay Borisov

When iterating the backrefs in an extent item if the ptr to the
'current' backref record goes beyond the extent item a warning is
generated and -ENOENT is returned. However what's more appropriate to
debug such cases would be to return EUCLEAN and also print the in-memory
state of the offending leaf.

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
 fs/btrfs/extent-tree.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 963160a0c393..5a53bcfdca83 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -895,7 +895,10 @@ int lookup_inline_extent_backref(struct btrfs_trans_handle *trans,
 	err = -ENOENT;
 	while (1) {
 		if (ptr >= end) {
-			WARN_ON(ptr > end);
+			if (WARN_ON(ptr > end)) {
+				err = -EUCLEAN;
+				btrfs_print_leaf(path->slots[0]);
+			}
 			break;
 		}
 		iref = (struct btrfs_extent_inline_ref *)ptr;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2022-04-22 10:11 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-04-20 11:54 [PATCH] btrfs: Improve error reporting in lookup_inline_extent_backref Nikolay Borisov
2022-04-20 14:52 ` David Sterba
2022-04-22 10:11   ` Filipe Manana
2022-04-20 15:54 ` David Sterba
2022-04-20 16:01   ` Nikolay Borisov
2022-04-21  6:40 ` kernel test robot
2022-04-21  6:41 ` kernel test robot
2022-04-21  6:43 ` kernel test robot
2022-04-21  6:44 ` kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox