All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] btrfs-progs: print-tree: Enhance warning on tree block level mismatch and error handling
@ 2018-03-15  4:48 Qu Wenruo
  2018-03-19 18:33 ` David Sterba
  0 siblings, 1 reply; 2+ messages in thread
From: Qu Wenruo @ 2018-03-15  4:48 UTC (permalink / raw)
  To: linux-btrfs

This patch enhance the tree block level mismatch by the following
methods:

1) Merge same warning branches into one
   We had two branches showing the same message, and their condition
   is also the same. Merge them

2) Only skip bad slot
   The old code skipped all the remaining slots, here we just skip one
   slot to output as many correct tree blocks as possible.

3) Enhance warning message
   Ouput the parent bytenr and expected and wrong level, so we don't
   need refer to the stdout to get which tree block is corrupted.

Signed-off-by: Qu Wenruo <wqu@suse.com>
---
 print-tree.c | 20 ++++++++------------
 1 file changed, 8 insertions(+), 12 deletions(-)

diff --git a/print-tree.c b/print-tree.c
index 45350fea0963..c1e7af65ce4b 100644
--- a/print-tree.c
+++ b/print-tree.c
@@ -1389,19 +1389,16 @@ void btrfs_print_tree(struct btrfs_root *root, struct extent_buffer *eb, int fol
 				(unsigned long long)btrfs_header_owner(eb));
 			continue;
 		}
-		if (btrfs_is_leaf(next) && btrfs_header_level(eb) != 1) {
-			warning(
-	"eb corrupted: item %d eb level %d next level %d, skipping the rest",
-				i, btrfs_header_level(next),
-				btrfs_header_level(eb));
-			goto out;
-		}
 		if (btrfs_header_level(next) != btrfs_header_level(eb) - 1) {
 			warning(
-	"eb corrupted: item %d eb level %d next level %d, skipping the rest",
-				i, btrfs_header_level(next),
-				btrfs_header_level(eb));
-			goto out;
+	"eb corrupted: parent bytenr %llu slot %d level %d child bytenr %llu level has %d expect %d, skipping the slot",
+				btrfs_header_bytenr(eb), i,
+				btrfs_header_level(eb),
+				btrfs_header_bytenr(next),
+				btrfs_header_level(next),
+				btrfs_header_level(eb) - 1);
+			free_extent_buffer(next);
+			continue;
 		}
 		btrfs_print_tree(root, next, 1);
 		free_extent_buffer(next);
@@ -1409,6 +1406,5 @@ void btrfs_print_tree(struct btrfs_root *root, struct extent_buffer *eb, int fol
 
 	return;
 
-out:
 	free_extent_buffer(next);
 }
-- 
2.16.2


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

* Re: [PATCH] btrfs-progs: print-tree: Enhance warning on tree block level mismatch and error handling
  2018-03-15  4:48 [PATCH] btrfs-progs: print-tree: Enhance warning on tree block level mismatch and error handling Qu Wenruo
@ 2018-03-19 18:33 ` David Sterba
  0 siblings, 0 replies; 2+ messages in thread
From: David Sterba @ 2018-03-19 18:33 UTC (permalink / raw)
  To: Qu Wenruo; +Cc: linux-btrfs

On Thu, Mar 15, 2018 at 12:48:15PM +0800, Qu Wenruo wrote:
> This patch enhance the tree block level mismatch by the following
> methods:
> 
> 1) Merge same warning branches into one
>    We had two branches showing the same message, and their condition
>    is also the same. Merge them
> 
> 2) Only skip bad slot
>    The old code skipped all the remaining slots, here we just skip one
>    slot to output as many correct tree blocks as possible.
> 
> 3) Enhance warning message
>    Ouput the parent bytenr and expected and wrong level, so we don't
>    need refer to the stdout to get which tree block is corrupted.
> 
> Signed-off-by: Qu Wenruo <wqu@suse.com>

Applied, thanks.

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

end of thread, other threads:[~2018-03-19 18:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-15  4:48 [PATCH] btrfs-progs: print-tree: Enhance warning on tree block level mismatch and error handling Qu Wenruo
2018-03-19 18:33 ` David Sterba

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.