From: Marcos Paulo de Souza <mpdesouza@suse.com>
To: linux-btrfs@vger.kernel.org
Cc: dsterba@suse.com, Marcos Paulo de Souza <mpdesouza@suse.com>
Subject: [PATCH] btrfs: ctree: Remove max argument from generic_bin_search
Date: Tue, 6 Jul 2021 15:13:25 -0300 [thread overview]
Message-ID: <20210706181325.6749-1-mpdesouza@suse.com> (raw)
Both callers use btrfs_header_nritems to feed the max argument.
Remove the argument and let generic_bin_search call it itself.
Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com>
---
fs/btrfs/ctree.c | 18 ++++++++----------
1 file changed, 8 insertions(+), 10 deletions(-)
diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
index c5c08c87e130..394fec1d3fd9 100644
--- a/fs/btrfs/ctree.c
+++ b/fs/btrfs/ctree.c
@@ -726,22 +726,22 @@ int btrfs_realloc_node(struct btrfs_trans_handle *trans,
/*
* search for key in the extent_buffer. The items start at offset p,
- * and they are item_size apart. There are 'max' items in p.
+ * and they are item_size apart.
*
* the slot in the array is returned via slot, and it points to
* the place where you would insert key if it is not found in
* the array.
*
- * slot may point to max if the key is bigger than all of the keys
+ * slot may point to total number of items if the key is bigger than
+ * all of the keys
*/
static noinline int generic_bin_search(struct extent_buffer *eb,
unsigned long p, int item_size,
- const struct btrfs_key *key,
- int max, int *slot)
+ const struct btrfs_key *key, int *slot)
{
- int low = 0;
- int high = max;
int ret;
+ int low = 0;
+ int high = btrfs_header_nritems(eb);
const int key_size = sizeof(struct btrfs_disk_key);
if (low > high) {
@@ -800,14 +800,12 @@ int btrfs_bin_search(struct extent_buffer *eb, const struct btrfs_key *key,
return generic_bin_search(eb,
offsetof(struct btrfs_leaf, items),
sizeof(struct btrfs_item),
- key, btrfs_header_nritems(eb),
- slot);
+ key, slot);
else
return generic_bin_search(eb,
offsetof(struct btrfs_node, ptrs),
sizeof(struct btrfs_key_ptr),
- key, btrfs_header_nritems(eb),
- slot);
+ key, slot);
}
static void root_add_used(struct btrfs_root *root, u32 size)
--
2.26.2
next reply other threads:[~2021-07-06 18:13 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-06 18:13 Marcos Paulo de Souza [this message]
2021-07-06 18:33 ` [PATCH] btrfs: ctree: Remove max argument from generic_bin_search Nikolay Borisov
2021-07-07 18:07 ` David Sterba
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210706181325.6749-1-mpdesouza@suse.com \
--to=mpdesouza@suse.com \
--cc=dsterba@suse.com \
--cc=linux-btrfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox