From: Liam R. Howlett Date: Wed, 24 Sep 2025 14:09:19 +0000 (-0400) Subject: drop dead code in data_fits() X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=ef798568430ba50f2bd41915dd6ba9f4a8fd255e;p=users%2Fjedix%2Flinux-maple.git drop dead code in data_fits() Don't check twice for data fitting for splits Signed-off-by: Liam R. Howlett --- diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 7c309bf93c84..62dda0474f1e 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -2424,11 +2424,10 @@ static inline void cp_data_calc(struct maple_copy *cp, static bool data_fits(struct ma_state *sib, struct ma_state *mas, struct maple_copy *cp) { - unsigned char space; unsigned char new_data; - unsigned char end; enum maple_type type; - void __rcu **slots; + unsigned char space; + unsigned char end; type = mte_node_type(mas->node); space = 2 * mt_slots[type]; @@ -2448,7 +2447,6 @@ static bool data_fits(struct ma_state *sib, struct ma_state *mas, * to reduce jitter. */ -#if 1 if (ma_is_leaf(type)) { if (new_data < space) @@ -2459,85 +2457,6 @@ static bool data_fits(struct ma_state *sib, struct ma_state *mas, } return false; -#else - /* Leave some room to reduce jitter. */ - if (new_data < space - 1) - return true; - - /* Leave some room to reduce jitter. */ - if (!ma_is_leaf(type)) - return false; - /* - * new_data == space, an exact fit can be foiled by a NULL at the split - * location. - */ - if (sib->max < mas->min) { - printk("Trying left\n"); - /* - * Pushing to left, there must be room so the last slot is not - * occupied. - * - * The new data is causing the two nodes to equate to exactly 32 - * in size, so the left must either have 1 or 2 slots empty. - */ - new_data = mt_slots[type] - end - 2; - if (mas->offset == new_data || - mas->offset + cp->end == new_data) { - printk("use cp "); - new_data -= mas->offset; - slots = cp->slot; - } else { - printk("use mas "); - slots = ma_slots(mas_mn(mas), type); - } - printk("Check slot %u\n", new_data); - } else { - unsigned char split; - /* - * Pushing to right, there must be an overflow of data into sib, - * which is almost full itself. - * - * The new data can add 1 or 2 entries in this case. - * The split must fall either in the new data or the end of the - * existing mas node. - */ - printk("Trying right\n"); - printk("data is %u end is %u\n", cp->data, end); - /* size - size to index (-1) */ - split = (new_data - 1) / 2; - printk("split will be %u\n", split); - - if (split >= mas->offset && - split <= mas->offset + cp->end + 1) { - new_data = split - mas->offset; - slots = cp->slot; - printk("Check new data %u\n", new_data); - } else { - if (mas->offset < split) { - printk("offset is smaller than expected split\n"); - printk("new_data %u offset %u end %u\n", new_data, mas->offset, cp->end); - /* - * The last slot in the previous node is the one - * before the overflow. - * The total is 32 here, so we know that it will - * be 16/16 split. - */ - - //new_data = mas->end - (split - end); - new_data = mas->end - (cp->data - 1 - split); - } - slots = ma_slots(mas_mn(mas), type); - printk("Check mas %u\n", new_data); - } - } - - fflush(stdout); - printk("Check %u\n", new_data); - if (slots[new_data]) - return true; - - return false; -#endif } static void push_data_sib(struct maple_copy *cp, struct ma_state *mas,