[8/9] maple_tree: Remove the redundant check of mas->offset in mas_empty_area/area_rev()

Message ID 20230425110511.11680-9-zhangpeng.00@bytedance.com
State New
Headers
Series fix, rework and clean up for maple tree |

Commit Message

Peng Zhang April 25, 2023, 11:05 a.m. UTC
  In mas_empty_area(), after mas_awalk() returns, if EBUSY is not set,
then mas->offset must be valid, no need to check. Same in
mas_empty_area_rev(), so delete it.

Signed-off-by: Peng Zhang <zhangpeng.00@bytedance.com>
---
 lib/maple_tree.c | 7 -------
 1 file changed, 7 deletions(-)
  

Comments

Liam R. Howlett April 25, 2023, 5 p.m. UTC | #1
* Peng Zhang <zhangpeng.00@bytedance.com> [230425 07:05]:

The subject doesn't need this much detail.  If mas->offset means
something to people reading through the git logs, they will already be
looking into the change.

> In mas_empty_area(), after mas_awalk() returns, if EBUSY is not set,
> then mas->offset must be valid, no need to check. Same in
> mas_empty_area_rev(), so delete it.

There is a lot of code in this message as well.

> 
> Signed-off-by: Peng Zhang <zhangpeng.00@bytedance.com>
> ---
>  lib/maple_tree.c | 7 -------
>  1 file changed, 7 deletions(-)
> 
> diff --git a/lib/maple_tree.c b/lib/maple_tree.c
> index 8bfa837b7b752..964214de2ed18 100644
> --- a/lib/maple_tree.c
> +++ b/lib/maple_tree.c
> @@ -5305,13 +5305,9 @@ int mas_empty_area(struct ma_state *mas, unsigned long min,
>  		return xa_err(mas->node);
>  
>  	offset = mas->offset;
> -	if (unlikely(offset == MAPLE_NODE_SLOTS))
> -		return -EBUSY;
> -
>  	mt = mte_node_type(mas->node);
>  	pivots = ma_pivots(mas_mn(mas), mt);
>  	mas->index = max(mas->index, mas_safe_min(mas, pivots, offset));
> -
>  	mas->last = mas->index + size - 1;
>  	return 0;
>  }
> @@ -5365,9 +5361,6 @@ int mas_empty_area_rev(struct ma_state *mas, unsigned long min,
>  	if (mas_is_err(mas))
>  		return xa_err(mas->node);
>  
> -	if (unlikely(mas->offset == MAPLE_NODE_SLOTS))
> -		return -EBUSY;
> -
>  	/* Trim the upper limit to the max. */
>  	if (max < mas->last)
>  		mas->last = max;
> -- 
> 2.20.1
>
  

Patch

diff --git a/lib/maple_tree.c b/lib/maple_tree.c
index 8bfa837b7b752..964214de2ed18 100644
--- a/lib/maple_tree.c
+++ b/lib/maple_tree.c
@@ -5305,13 +5305,9 @@  int mas_empty_area(struct ma_state *mas, unsigned long min,
 		return xa_err(mas->node);
 
 	offset = mas->offset;
-	if (unlikely(offset == MAPLE_NODE_SLOTS))
-		return -EBUSY;
-
 	mt = mte_node_type(mas->node);
 	pivots = ma_pivots(mas_mn(mas), mt);
 	mas->index = max(mas->index, mas_safe_min(mas, pivots, offset));
-
 	mas->last = mas->index + size - 1;
 	return 0;
 }
@@ -5365,9 +5361,6 @@  int mas_empty_area_rev(struct ma_state *mas, unsigned long min,
 	if (mas_is_err(mas))
 		return xa_err(mas->node);
 
-	if (unlikely(mas->offset == MAPLE_NODE_SLOTS))
-		return -EBUSY;
-
 	/* Trim the upper limit to the max. */
 	if (max < mas->last)
 		mas->last = max;