From d781921bc8f9fe0720856a0956fbf3d4119a5180 Mon Sep 17 00:00:00 2001 From: "Liam R. Howlett" Date: Mon, 1 May 2023 20:33:56 -0400 Subject: [PATCH] maple_tree: Move mas_wr_modify node size calculation to mas_wr_node_size() 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 --- lib/maple_tree.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 36abd3d76cfb5..4d312aea2263a 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -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)) -- 2.50.1