[SRU][B][PATCH 1/6] Revert "btrfs: Detect unbalanced tree with empty leaf before crashing btree operations"

Matthew Ruffell matthew.ruffell at canonical.com
Wed Jul 7 04:40:32 UTC 2021


BugLink: https://bugs.launchpad.net/bugs/1934709

This reverts commit 4ee43ff1826c2ebc84c569750b7a0977a625c970.

A mistake was made in the backport of the below commit:

ubuntu-bionic 50ab1ff51db0c5eb77ffc6f15ef32f07764f86ff
Author: Qu Wenruo <wqu at suse.com>
Date:   Thu Mar 29 09:08:11 2018 +0800
Subject: btrfs: Validate child tree block's level and first key
Link: https://paste.ubuntu.com/p/DQjTkfNRDt/

This commit is applied ontop of the problematic commit, making it a dependency
for revert. We will revert this commit, and re-apply it after the corrected
"btrfs: Validate child tree block's level and first key" has been applied.

Signed-off-by: Matthew Ruffell <matthew.ruffell at canonical.com>
---
 fs/btrfs/disk-io.c      | 9 ---------
 fs/btrfs/tree-checker.c | 7 -------
 2 files changed, 16 deletions(-)

diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 9a80f50e532a..62ece41660ae 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -459,15 +459,6 @@ static int verify_level_key(struct btrfs_fs_info *fs_info,
 	if (!first_key)
 		return 0;
 
-	/* We have @first_key, so this @eb must have at least one item */
-	if (btrfs_header_nritems(eb) == 0) {
-		btrfs_err(fs_info,
-		"invalid tree nritems, bytenr=%llu nritems=0 expect >0",
-			  eb->start);
-		WARN_ON(IS_ENABLED(CONFIG_BTRFS_DEBUG));
-		return -EUCLEAN;
-	}
-
 	if (found_level)
 		btrfs_node_key_to_cpu(eb, &found_key, 0);
 	else
diff --git a/fs/btrfs/tree-checker.c b/fs/btrfs/tree-checker.c
index 8cc527fd6f5b..1e0516b3d1d6 100644
--- a/fs/btrfs/tree-checker.c
+++ b/fs/btrfs/tree-checker.c
@@ -1354,13 +1354,6 @@ static int check_leaf(struct extent_buffer *leaf, bool check_item_data)
 				    owner);
 			return -EUCLEAN;
 		}
-		/* Unknown tree */
-		if (owner == 0) {
-			generic_err(leaf, 0,
-				"invalid owner, root 0 is not defined");
-			return -EUCLEAN;
-		}
-
 		key.objectid = owner;
 		key.type = BTRFS_ROOT_ITEM_KEY;
 		key.offset = (u64)-1;
-- 
2.30.2




More information about the kernel-team mailing list