Commit 27260dd1 authored by Sun YangKai's avatar Sun YangKai Committed by David Sterba
Browse files

btrfs: remove partial support for lowest level from btrfs_search_forward()



Commit 323ac95b ("Btrfs: don't read leaf blocks containing only
checksums during truncate") changed the condition from `level == 0` to
`level == path->lowest_level`, while its original purpose was just to do
some leaf node handling (calling btrfs_item_key_to_cpu()) and skip some
code that doesn't fit leaf nodes.

After changing the condition, the code path:

1. Also handles the non-leaf nodes when path->lowest_level is nonzero,
   which is wrong. However btrfs_search_forward() is never called with a
   nonzero path->lowest_level, which makes this bug not found before.

2. Makes the later if block with the same condition, which was originally
   used to handle non-leaf node (calling btrfs_node_key_to_cpu()) when
   lowest_level is not zero, dead code.

Since btrfs_search_forward() is never called for a path with a
lowest_level different from zero, just completely remove the partial
support for a non-zero lowest_level, simplifying a bit the code, and
assert that lowest_level is zero at the start of the function.

Suggested-by: default avatarQu Wenruo <wqu@suse.com>
Fixes: 323ac95b ("Btrfs: don't read leaf blocks containing only checksums during truncate")
Reviewed-by: default avatarFilipe Manana <fdmanana@suse.com>
Signed-off-by: default avatarSun YangKai <sunk67188@gmail.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent c9da2242
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment