summaryrefslogtreecommitdiffstats
path: root/fs/btrfs/tree-checker.c
diff options
context:
space:
mode:
authorQu Wenruo <wqu@suse.com>2019-04-03 23:47:07 -0400
committerDavid Sterba <dsterba@suse.com>2019-04-29 13:02:39 -0400
commitff2ac107fae2440b6877c615c0ac788d2a106ed7 (patch)
tree6c2785e665c822386f54f5416e7e8a2d04f63095 /fs/btrfs/tree-checker.c
parent39ad317315887c2cb9a4347a93a8859326ddf136 (diff)
btrfs: tree-checker: Remove comprehensive root owner check
Commit 1ba98d086fe3 ("Btrfs: detect corruption when non-root leaf has zero item") introduced comprehensive root owner checker. However it's pretty expensive tree search to locate the owner root, especially when it get reused by mandatory read and write time tree-checker. This patch will remove that check, and completely rely on owner based empty leaf check, which is much faster and still works fine for most case. And since we skip the old root owner check, now write time tree check can be merged with btrfs_check_leaf_full(). Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/tree-checker.c')
-rw-r--r--fs/btrfs/tree-checker.c24
1 files changed, 0 insertions, 24 deletions
diff --git a/fs/btrfs/tree-checker.c b/fs/btrfs/tree-checker.c
index 5c988b57b90e..b9dd2a6e133f 100644
--- a/fs/btrfs/tree-checker.c
+++ b/fs/btrfs/tree-checker.c
@@ -831,7 +831,6 @@ static int check_leaf(struct extent_buffer *leaf, bool check_item_data)
831 */ 831 */
832 if (nritems == 0 && !btrfs_header_flag(leaf, BTRFS_HEADER_FLAG_RELOC)) { 832 if (nritems == 0 && !btrfs_header_flag(leaf, BTRFS_HEADER_FLAG_RELOC)) {
833 u64 owner = btrfs_header_owner(leaf); 833 u64 owner = btrfs_header_owner(leaf);
834 struct btrfs_root *check_root;
835 834
836 /* These trees must never be empty */ 835 /* These trees must never be empty */
837 if (owner == BTRFS_ROOT_TREE_OBJECTID || 836 if (owner == BTRFS_ROOT_TREE_OBJECTID ||
@@ -845,29 +844,6 @@ static int check_leaf(struct extent_buffer *leaf, bool check_item_data)
845 owner); 844 owner);
846 return -EUCLEAN; 845 return -EUCLEAN;
847 } 846 }
848 key.objectid = owner;
849 key.type = BTRFS_ROOT_ITEM_KEY;
850 key.offset = (u64)-1;
851
852 check_root = btrfs_get_fs_root(fs_info, &key, false);
853 /*
854 * The only reason we also check NULL here is that during
855 * open_ctree() some roots has not yet been set up.
856 */
857 if (!IS_ERR_OR_NULL(check_root)) {
858 struct extent_buffer *eb;
859
860 eb = btrfs_root_node(check_root);
861 /* if leaf is the root, then it's fine */
862 if (leaf != eb) {
863 generic_err(leaf, 0,
864 "invalid nritems, have %u should not be 0 for non-root leaf",
865 nritems);
866 free_extent_buffer(eb);
867 return -EUCLEAN;
868 }
869 free_extent_buffer(eb);
870 }
871 return 0; 847 return 0;
872 } 848 }
873 849