All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] btrfs: ctree: Remove max argument from generic_bin_search
@ 2021-07-06 18:13 Marcos Paulo de Souza
  2021-07-06 18:33 ` Nikolay Borisov
  2021-07-07 18:07 ` David Sterba
  0 siblings, 2 replies; 3+ messages in thread
From: Marcos Paulo de Souza @ 2021-07-06 18:13 UTC (permalink / raw)
  To: linux-btrfs; +Cc: dsterba, Marcos Paulo de Souza

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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] btrfs: ctree: Remove max argument from generic_bin_search
  2021-07-06 18:13 [PATCH] btrfs: ctree: Remove max argument from generic_bin_search Marcos Paulo de Souza
@ 2021-07-06 18:33 ` Nikolay Borisov
  2021-07-07 18:07 ` David Sterba
  1 sibling, 0 replies; 3+ messages in thread
From: Nikolay Borisov @ 2021-07-06 18:33 UTC (permalink / raw)
  To: Marcos Paulo de Souza, linux-btrfs; +Cc: dsterba



On 6.07.21 г. 21:13, Marcos Paulo de Souza wrote:
> 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>

Reviewed-by: Nikolay Borisov <nborisov@suse.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] btrfs: ctree: Remove max argument from generic_bin_search
  2021-07-06 18:13 [PATCH] btrfs: ctree: Remove max argument from generic_bin_search Marcos Paulo de Souza
  2021-07-06 18:33 ` Nikolay Borisov
@ 2021-07-07 18:07 ` David Sterba
  1 sibling, 0 replies; 3+ messages in thread
From: David Sterba @ 2021-07-07 18:07 UTC (permalink / raw)
  To: Marcos Paulo de Souza; +Cc: linux-btrfs, dsterba

On Tue, Jul 06, 2021 at 03:13:25PM -0300, Marcos Paulo de Souza wrote:
> 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>

Added to misc-next, thanks.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-07-07 18:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-06 18:13 [PATCH] btrfs: ctree: Remove max argument from generic_bin_search Marcos Paulo de Souza
2021-07-06 18:33 ` Nikolay Borisov
2021-07-07 18:07 ` David Sterba

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.