From: Liam R. Howlett Date: Tue, 22 Mar 2022 16:38:04 +0000 (-0400) Subject: maple_tree: change mas_split_final_node() logic a bit X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=9f9fbd48d01ea341aed0e20fd6b4bcfeb44150fa;p=users%2Fjedix%2Flinux-maple.git maple_tree: change mas_split_final_node() logic a bit Signed-off-by: Liam R. Howlett --- diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 597c73d1f91d..1bd8a4c2504e 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -3236,30 +3236,25 @@ static inline bool mas_split_final_node(struct maple_split_state *mss, static inline void mss_fill_bnode(struct maple_split_state *mss, struct ma_state *mas, unsigned char skip) { - bool cp = true; + bool cp = false; struct maple_enode *old = mas->node; unsigned char split; memset(mss->bn, 0, sizeof(struct maple_big_node)); - if (mte_is_root(mas->node)) { - cp = false; - } else { + if (!mte_is_root(mas->node)) { + cp = true; mas_ascend(mas); mat_add(mss->free, old); mas->offset = mte_parent_slot(mas->node); + if (mss->l->offset) + mas_mab_cp(mas, 0, mss->l->offset - 1, mss->bn, 0); } - if (cp && mss->l->offset) - mas_mab_cp(mas, 0, mss->l->offset - 1, mss->bn, 0); - split = mss->bn->b_end; mab_set_b_end(mss->bn, mss->l, mss->l->node); mss->r->offset = mss->bn->b_end; mab_set_b_end(mss->bn, mss->r, mss->r->node); - if (mss->bn->pivot[mss->bn->b_end - 1] == mas->max) - cp = false; - - if (cp) + if (cp && (mss->bn->pivot[mss->bn->b_end - 1] != mas->max)) mas_mab_cp(mas, split + skip, mt_slot_count(mas->node) - 1, mss->bn, mss->bn->b_end);