Skip to content

Commit 253002f

Browse files
fdmananakdave
authored andcommitted
Btrfs: remove assertion when searching for a key in a node/leaf
At ctree.c:key_search(), the assertion that verifies the first key on a child extent buffer corresponds to the key at a specific slot in the parent has a disadvantage: we effectively hit a BUG_ON() which requires rebooting the machine later. It also does not tell any information about which extent buffer is affected, from which root, the expected and found keys, etc. However as of commit 581c176 ("btrfs: Validate child tree block's level and first key"), that assertion is not needed since at the time we read an extent buffer from disk we validate that its first key matches the key, at the respective slot, in the parent extent buffer. Therefore just remove the assertion at key_search(). Reviewed-by: Qu Wenruo <wqu@suse.com> Signed-off-by: Filipe Manana <fdmanana@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
1 parent cbca7d5 commit 253002f

File tree

1 file changed

+0
-21
lines changed

1 file changed

+0
-21
lines changed

fs/btrfs/ctree.c

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2544,26 +2544,6 @@ setup_nodes_for_search(struct btrfs_trans_handle *trans,
25442544
return ret;
25452545
}
25462546

2547-
static void key_search_validate(struct extent_buffer *b,
2548-
const struct btrfs_key *key,
2549-
int level)
2550-
{
2551-
#ifdef CONFIG_BTRFS_ASSERT
2552-
struct btrfs_disk_key disk_key;
2553-
2554-
btrfs_cpu_key_to_disk(&disk_key, key);
2555-
2556-
if (level == 0)
2557-
ASSERT(!memcmp_extent_buffer(b, &disk_key,
2558-
offsetof(struct btrfs_leaf, items[0].key),
2559-
sizeof(disk_key)));
2560-
else
2561-
ASSERT(!memcmp_extent_buffer(b, &disk_key,
2562-
offsetof(struct btrfs_node, ptrs[0].key),
2563-
sizeof(disk_key)));
2564-
#endif
2565-
}
2566-
25672547
static int key_search(struct extent_buffer *b, const struct btrfs_key *key,
25682548
int level, int *prev_cmp, int *slot)
25692549
{
@@ -2572,7 +2552,6 @@ static int key_search(struct extent_buffer *b, const struct btrfs_key *key,
25722552
return *prev_cmp;
25732553
}
25742554

2575-
key_search_validate(b, key, level);
25762555
*slot = 0;
25772556

25782557
return 0;

0 commit comments

Comments
 (0)