diff mbox series

[1/7] maple_tree: not necessary to check ahead if !content

Message ID 20241127012753.3393-2-richard.weiyang@gmail.com (mailing list archive)
State New
Headers show
Series spanning write related cleanup | expand

Commit Message

Wei Yang Nov. 27, 2024, 1:27 a.m. UTC
Just like mas_wr_extend_null(), only when content is not NULL, we may
have a NULL slot ahead.

So we can wrap it in an else.

Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
CC: Liam R. Howlett <Liam.Howlett@Oracle.com>
CC: Sidhartha Kumar <sidhartha.kumar@oracle.com>
CC: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
---
 lib/maple_tree.c | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)
diff mbox series

Patch

diff --git a/lib/maple_tree.c b/lib/maple_tree.c
index 7efb1520f9bd..98692704d773 100644
--- a/lib/maple_tree.c
+++ b/lib/maple_tree.c
@@ -3568,18 +3568,20 @@  static inline void mas_extend_spanning_null(struct ma_wr_state *l_wr_mas,
 	unsigned char l_slot;
 
 	l_slot = l_mas->offset;
-	if (!l_wr_mas->content)
+	if (!l_wr_mas->content) {
+		/* If this one is null, the next and prev are not */
 		l_mas->index = l_wr_mas->r_min;
+	} else {
+		if ((l_mas->index == l_wr_mas->r_min) &&
+			 (l_slot &&
+			  !mas_slot_locked(l_mas, l_wr_mas->slots, l_slot - 1))) {
+			if (l_slot > 1)
+				l_mas->index = l_wr_mas->pivots[l_slot - 2] + 1;
+			else
+				l_mas->index = l_mas->min;
 
-	if ((l_mas->index == l_wr_mas->r_min) &&
-		 (l_slot &&
-		  !mas_slot_locked(l_mas, l_wr_mas->slots, l_slot - 1))) {
-		if (l_slot > 1)
-			l_mas->index = l_wr_mas->pivots[l_slot - 2] + 1;
-		else
-			l_mas->index = l_mas->min;
-
-		l_mas->offset = l_slot - 1;
+			l_mas->offset = l_slot - 1;
+		}
 	}
 
 	if (!r_wr_mas->content) {