From d78fffa43353f09e0b86ab3add91519a378780ed Mon Sep 17 00:00:00 2001 From: "Liam R. Howlett" Date: Tue, 4 Aug 2020 10:15:41 -0400 Subject: [PATCH] maple_tree: Fix splitting causing deficient nodes. When splitting a node, ensure a deficient node is not created when a NULL in encountered at the split. Also adjust the checking of the limit when incrementing to ensure both the min and the number on the right are zero based. Signed-off-by: Liam R. Howlett --- lib/maple_tree.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index fb28b36cd79e..1bf8b7a8d644 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -1487,7 +1487,7 @@ static inline int mab_no_null_split(struct maple_big_node *b_node, /* If the split is less than the max slot && the right side will * still be sufficient, then increment the split on NULL. */ - if ((split < slot_cnt - 1) && + if ((split < mt_slots[b_node->type] - 1) && (b_node->b_end - split) < (mt_min_slots[b_node->type])) split++; else @@ -1521,7 +1521,7 @@ static inline int mab_calc_split(struct maple_big_node *b_node, */ while (((b_node->pivot[split] - b_node->min) < slot_cnt - 1) && (split < slot_cnt - 1) && - (b_node->b_end - split > mt_min_slots[b_node->type])) + (b_node->b_end - split > mt_min_slots[b_node->type] - 1)) split++; } -- 2.50.1