]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
maple_tree: Move mas_wr_modify node size calculation to mas_wr_node_size()
authorLiam R. Howlett <Liam.Howlett@oracle.com>
Tue, 2 May 2023 00:33:56 +0000 (20:33 -0400)
committerLiam R. Howlett <Liam.Howlett@oracle.com>
Tue, 2 May 2023 03:00:31 +0000 (23:00 -0400)
Create a new function to get the size of the mas_wr_node_size() since it
will be used elsewhere soon.

Drop the incrementing of the node size if this is the left-most node.

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
lib/maple_tree.c

index 36abd3d76cfb5dca74c74562831b02203d7c4ee7..4d312aea2263a080b4121105170cb7bf5adeb4a5 100644 (file)
@@ -4382,6 +4382,11 @@ static void mas_wr_bnode(struct ma_wr_state *wr_mas)
        mas_commit_b_node(wr_mas, &b_node, wr_mas->node_end);
 }
 
+static inline unsigned char mas_wr_node_size(struct ma_wr_state *wr_mas)
+{
+       return wr_mas->node_end - wr_mas->offset_end + wr_mas->mas->offset + 2;
+}
+
 static inline void mas_wr_modify(struct ma_wr_state *wr_mas)
 {
        unsigned char node_slots;
@@ -4398,9 +4403,7 @@ static inline void mas_wr_modify(struct ma_wr_state *wr_mas)
 
        /* Attempt to append */
        node_slots = mt_slots[wr_mas->type];
-       node_size = wr_mas->node_end - wr_mas->offset_end + mas->offset + 2;
-       if (mas->max == ULONG_MAX)
-               node_size++;
+       node_size = mas_wr_node_size(wr_mas);
 
        /* slot and node store will not fit, go to the slow path */
        if (unlikely(node_size >= node_slots))