From e3b8336117e515a260da32fa10bb3354ba12c429 Mon Sep 17 00:00:00 2001 From: Qu Wenruo Date: Fri, 17 Apr 2020 15:08:21 +0800 Subject: btrfs: remove the redundant parameter level in btrfs_bin_search() All callers pass the eb::level so we can get read it directly inside the btrfs_bin_search and key_search. This is inspired by the work of Marek in U-boot. CC: Marek Behun Reviewed-by: Johannes Thumshirn Reviewed-by: Nikolay Borisov Signed-off-by: Qu Wenruo Reviewed-by: David Sterba Signed-off-by: David Sterba --- fs/btrfs/ctree.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'fs/btrfs/ctree.c') diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c index bfedbbe2311f..6c28efe5b14a 100644 --- a/fs/btrfs/ctree.c +++ b/fs/btrfs/ctree.c @@ -1733,9 +1733,9 @@ static noinline int generic_bin_search(struct extent_buffer *eb, * leaves vs nodes */ int btrfs_bin_search(struct extent_buffer *eb, const struct btrfs_key *key, - int level, int *slot) + int *slot) { - if (level == 0) + if (btrfs_header_level(eb) == 0) return generic_bin_search(eb, offsetof(struct btrfs_leaf, items), sizeof(struct btrfs_item), @@ -2502,10 +2502,10 @@ done: } static int key_search(struct extent_buffer *b, const struct btrfs_key *key, - int level, int *prev_cmp, int *slot) + int *prev_cmp, int *slot) { if (*prev_cmp != 0) { - *prev_cmp = btrfs_bin_search(b, key, level, slot); + *prev_cmp = btrfs_bin_search(b, key, slot); return *prev_cmp; } @@ -2783,7 +2783,7 @@ cow_done: } } - ret = key_search(b, key, level, &prev_cmp, &slot); + ret = key_search(b, key, &prev_cmp, &slot); if (ret < 0) goto done; @@ -2947,7 +2947,7 @@ again: * time. */ prev_cmp = -1; - ret = key_search(b, key, level, &prev_cmp, &slot); + ret = key_search(b, key, &prev_cmp, &slot); if (ret < 0) goto done; @@ -5103,7 +5103,7 @@ again: while (1) { nritems = btrfs_header_nritems(cur); level = btrfs_header_level(cur); - sret = btrfs_bin_search(cur, min_key, level, &slot); + sret = btrfs_bin_search(cur, min_key, &slot); if (sret < 0) { ret = sret; goto out; -- cgit v1.2.3