From: Liam R. Howlett Date: Tue, 2 May 2023 00:33:56 +0000 (-0400) Subject: maple_tree: Move mas_wr_modify node size calculation to mas_wr_node_size() X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=d781921bc8f9fe0720856a0956fbf3d4119a5180;p=users%2Fjedix%2Flinux-maple.git 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 --- diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 36abd3d76cfb..4d312aea2263 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))