]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
Change mas_wmb_replace() to do include the setup
authorLiam R. Howlett <Liam.Howlett@oracle.com>
Wed, 24 Sep 2025 16:48:21 +0000 (12:48 -0400)
committerLiam R. Howlett <Liam.Howlett@oracle.com>
Wed, 24 Sep 2025 19:37:58 +0000 (15:37 -0400)
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
lib/maple_tree.c

index c03ca621c366c509ee94c05cbbe4dbcee089a629..7c6cd898dd43afe5746b24066b39e99cfe62673c 100644 (file)
@@ -2171,26 +2171,6 @@ static inline void mas_topiary_replace(struct ma_state *mas,
        mas_mat_destroy(mas, &subtrees);
 }
 
-/*
- * mas_wmb_replace() - Write memory barrier and replace
- * @mas: The maple state
- * @old_enode: The old maple encoded node that is being replaced.
- * @new_height: The new height of the tree as a result of the operation
- *
- * Updates gap as necessary.
- */
-static inline void mas_wmb_replace(struct ma_state *mas,
-               struct maple_enode *old_enode, unsigned char new_height)
-{
-       /* Insert the new data in the tree */
-       mas_topiary_replace(mas, old_enode, new_height);
-
-       if (mte_is_leaf(mas->node))
-               return;
-
-       mas_update_gap(mas);
-}
-
 static inline void *mtree_range_walk(struct ma_state *mas)
 {
        unsigned long *pivots;
@@ -2251,6 +2231,28 @@ dead_node:
        return NULL;
 }
 
+/*
+ * mas_wmb_replace() - Write memory barrier and replace
+ * @mas: The maple state
+ * @old_enode: The old maple encoded node that is being replaced.
+ * @new_height: The new height of the tree as a result of the operation
+ *
+ * Updates gap as necessary.
+ */
+static inline void mas_wmb_replace(struct ma_state *mas, struct maple_copy *cp)
+{
+       struct maple_enode *old_enode;
+
+       old_enode = mas->node;
+       mas->node = cp->slot[0];
+       /* Insert the new data in the tree */
+       mas_topiary_replace(mas, old_enode, cp->height);
+       if (!mte_is_leaf(mas->node))
+               mas_update_gap(mas);
+
+       mtree_range_walk(mas);
+}
+
 
 /* Direct node to node copy */
 static inline
@@ -3356,6 +3358,7 @@ done:
 
        return;
 }
+
 /*
  * mas_wr_spanning_store() - Create a subtree with the store operation completed
  * and new nodes where necessary, then place the sub-tree in the actual tree.
@@ -3365,7 +3368,6 @@ done:
  */
 static void mas_wr_spanning_store(struct ma_wr_state *wr_mas)
 {
-       struct maple_enode *old_enode;
        struct maple_copy cp;
        struct ma_state *mas;
        struct ma_state sib;
@@ -3441,10 +3443,7 @@ static void mas_wr_spanning_store(struct ma_wr_state *wr_mas)
                cp_data_write(&cp, mas);
        } while (spanning_ascend(&cp, mas, wr_mas, &r_wr_mas, &sib));
 
-       old_enode = mas->node;
-       mas->node = cp.slot[0];
-       mas_wmb_replace(mas, old_enode, cp.height);
-       mtree_range_walk(mas);
+       mas_wmb_replace(mas, &cp);
 }
 
 /*
@@ -3771,7 +3770,6 @@ static void split_data(struct maple_copy *cp,
  */
 static void mas_wr_split(struct ma_wr_state *wr_mas)
 {
-       struct maple_enode *old_enode;
        struct ma_state *mas;
        struct maple_copy cp;
        struct ma_state sib;
@@ -3787,10 +3785,7 @@ static void mas_wr_split(struct ma_wr_state *wr_mas)
                cp_data_write(&cp, mas);
        } while (split_ascend(&cp, wr_mas, &sib));
 
-       old_enode = mas->node;
-       mas->node = cp.slot[0];
-       mas_wmb_replace(mas, old_enode, cp.height);
-       mtree_range_walk(mas);
+       mas_wmb_replace(mas, &cp);
 }
 
 /*
@@ -3804,8 +3799,6 @@ static void mas_wr_split(struct ma_wr_state *wr_mas)
  */
 static void mas_wr_rebalance(struct ma_wr_state *wr_mas)
 {
-
-       struct maple_enode *old_enode;
        struct ma_state *mas;
        struct maple_copy cp;
        struct ma_state sib;
@@ -3831,10 +3824,7 @@ static void mas_wr_rebalance(struct ma_wr_state *wr_mas)
                cp_data_write(&cp, mas);
        } while (rebalance_ascend(&cp, wr_mas, &sib));
 
-       old_enode = mas->node;
-       mas->node = cp.slot[0];
-       mas_wmb_replace(mas, old_enode, cp.height);
-       mtree_range_walk(mas);
+       mas_wmb_replace(mas, &cp);
 }
 
 /*