diff mbox series

[13/18] maple_tree: simplify mas_commit_b_node()

Message ID 20240604174145.563900-14-sidhartha.kumar@oracle.com (mailing list archive)
State New
Headers show
Series Introduce a store type enum for the Maple tree | expand

Commit Message

Sidhartha Kumar June 4, 2024, 5:41 p.m. UTC
Use mas->store_type to simplify the logic of identifying the type of
write.

Signed-off-by: Sidhartha Kumar <sidhartha.kumar@oracle.com>
---
 lib/maple_tree.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

Comments

Liam R. Howlett June 4, 2024, 7:34 p.m. UTC | #1
* Sidhartha Kumar <sidhartha.kumar@oracle.com> [240604 13:42]:
> Use mas->store_type to simplify the logic of identifying the type of
> write.

Since b_type is now only used in one location, we can use
mas_new_ma_node() instead of mt_mk_node() and remove b_type entirely
from this function.  This is also true of the maple_node *node pointer.

old_enode and b_end could also be moved below all the returns as they
are only used after all the other options.

> 
> Signed-off-by: Sidhartha Kumar <sidhartha.kumar@oracle.com>
> ---
>  lib/maple_tree.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/lib/maple_tree.c b/lib/maple_tree.c
> index 314691fd1c67..faadddbe2086 100644
> --- a/lib/maple_tree.c
> +++ b/lib/maple_tree.c
> @@ -3437,12 +3437,10 @@ static noinline_for_kasan int mas_commit_b_node(struct ma_wr_state *wr_mas,
>  	enum maple_type b_type = b_node->type;
>  
>  	old_enode = wr_mas->mas->node;
> -	if ((b_end < mt_min_slots[b_type]) &&
> -	    (!mte_is_root(old_enode)) &&
> -	    (mas_mt_height(wr_mas->mas) > 1))
> +	if (wr_mas->mas->store_type == wr_rebalance)
>  		return mas_rebalance(wr_mas->mas, b_node);
>  
> -	if (b_end >= mt_slots[b_type])
> +	if (wr_mas->mas->store_type == wr_split_store)
>  		return mas_split(wr_mas->mas, b_node);
>  
>  	if (mas_reuse_node(wr_mas, b_node, end))
> -- 
> 2.45.1
>
diff mbox series

Patch

diff --git a/lib/maple_tree.c b/lib/maple_tree.c
index 314691fd1c67..faadddbe2086 100644
--- a/lib/maple_tree.c
+++ b/lib/maple_tree.c
@@ -3437,12 +3437,10 @@  static noinline_for_kasan int mas_commit_b_node(struct ma_wr_state *wr_mas,
 	enum maple_type b_type = b_node->type;
 
 	old_enode = wr_mas->mas->node;
-	if ((b_end < mt_min_slots[b_type]) &&
-	    (!mte_is_root(old_enode)) &&
-	    (mas_mt_height(wr_mas->mas) > 1))
+	if (wr_mas->mas->store_type == wr_rebalance)
 		return mas_rebalance(wr_mas->mas, b_node);
 
-	if (b_end >= mt_slots[b_type])
+	if (wr_mas->mas->store_type == wr_split_store)
 		return mas_split(wr_mas->mas, b_node);
 
 	if (mas_reuse_node(wr_mas, b_node, end))