From 63ddc2b368ae1f294d10275149e6d83eb8243c76 Mon Sep 17 00:00:00 2001 From: "Liam R. Howlett" Date: Mon, 28 Sep 2020 15:20:00 -0400 Subject: [PATCH] maple_tree: Drop if 0 code Signed-off-by: Liam R. Howlett --- lib/maple_tree.c | 234 ----------------------------------------------- 1 file changed, 234 deletions(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 2c17eef5a426..7e415e5ef0aa 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -3010,240 +3010,6 @@ static inline int mas_spanning_store(struct ma_state *mas, void *entry) return mas_spanning_rebalance(mas, &mast, height + 1); } -#if 0 -static inline bool mas_append(struct ma_state *mas, void **slots, - unsigned long *pivots, unsigned char offset, - unsigned char slot_cnt, void *entry, void *content) -{ - /* Offset is where this data will go, aka the old end slot. */ - unsigned long min = mas_safe_min(mas, pivots, offset); - unsigned long max = mas_logical_pivot(mas, pivots, offset, - mte_node_type(mas->node)); - - mt_dump(mas->tree); - printk("%s Insert %lu-%lu\n", __func__, mas->index, mas->last); - printk("slot %u is %lu-%lu\n", offset, min, max); - printk("slot_cnt %u\n", slot_cnt); - if (max != mas->last) { - slots[slot_cnt] = content; - printk("Set slot %u to contents of slot %u\n", slot_cnt, offset); - pivots[slot_cnt] = pivots[offset]; - slot_cnt--; - } - - printk("Set slot %u to new value\n", slot_cnt); - slots[slot_cnt] = entry; - pivots[slot_cnt] = mas->last; - - if (min != mas->index) - pivots[offset] = mas->index - 1; - - mas_update_gap(mas); - return true; -} - -static inline void -mas_truncate(struct ma_state *mas, void **slots, unsigned long *pivots, - unsigned char offset, char shift, void *entry, unsigned char end) -{ - enum maple_type mt = mte_node_type(mas->node); - unsigned char size; - unsigned long r_min; - int src; - - mt_dump(mas->tree); - printk("%s Insert %lu-%lu\n", __func__, mas->index, mas->last); - - r_min = mas_safe_min(mas, pivots, offset); - if (r_min != mas->index) - pivots[offset++] = mas->index - 1; - - slots[offset] = entry; - pivots[offset] = mas->last; - - if (offset > shift + end) - return; - - // Now we are at offset, we have to skip -shift amount. - printk("src = %u - %d\n", offset, shift); - src = offset - shift; - size = end - offset; - printk("Insert cp offset %u => src %u size %u\n", offset, src, size); - memmove(pivots + offset, pivots + src, sizeof(unsigned long) * size); - memset(pivots+src+1, 0, sizeof(unsigned long) * (mt_slots[mt] - src)); - memmove(slots + offset, slots + src, sizeof(void *) * size); - memset(slots + src + 1, 0, sizeof(void *) * (mt_slots[mt] - src)); -} - -static inline void -mas_expand(struct ma_state *mas, void **slots, unsigned long *pivots, - unsigned char offset, char shift, void *entry, unsigned char end) -{ - enum maple_type mt = mte_node_type(mas->node); - unsigned char size = end + shift - offset; - unsigned long r_min, r_max; - int dst = offset + shift; - int src = offset; - mt_dump(mas->tree); - printk("%s Insert %lu-%lu\n", __func__, mas->index, mas->last); - printk("dst is %u + %u\n", offset, shift); - - r_max = mas_logical_pivot(mas, pivots, offset, mt); - if (r_max > mas->last) - src += 1; - - printk("Expand: dst %u src %u size %u\n", dst, src, size); - printk("Expand: shift %u src %u size %u\n", shift, src, size); - printk("r_max = %lu\n", r_max); - - memmove(pivots + dst, pivots + src, - sizeof(unsigned long) * min(size, (unsigned char)(mt_pivots[mt] - 1))); - memmove(slots + dst, slots + src, sizeof(void *) * size); - - r_min = mas_safe_min(mas, pivots, offset); - if (r_min != mas->index) - pivots[offset++] = mas->index - 1; - - slots[offset] = entry; - pivots[offset] = mas->last; -} - -static inline bool _mas_med_path(struct ma_state *mas, void *entry, - unsigned char end, void *content) -{ - enum maple_type mt = mte_node_type(mas->node); - struct maple_node *node = mte_to_node(mas->node); - unsigned char offset = mas_offset(mas); //may have changed on extend null. - unsigned char slot_max = mt_slots[mt]; - unsigned char slot_cnt, new_end; - char shift; - unsigned long r_min, r_max, *pivots = ma_pivots(node, mt); - void **slots = ma_slots(node, mt); - - if (end < mt_pivots[mt] - 1 && pivots[end] < mas->max) - end++; - - slot_cnt = end; - - if (offset >= slot_max) - offset = end; - - /* Cannot use mas_safe_min due to piv + 1 below */ - r_min = mas->min - 1; - if (offset) - r_min = pivots[offset - 1]; - - if (r_min + 1 < mas->index) // insert starts later than this range. - slot_cnt++; - - r_min++; - r_max = mas_logical_pivot(mas, pivots, offset, mt); - if (r_max > mas->last) { // insert ends before this range. - slot_cnt++; - } else if (r_max < mas->last) { // insert overwrites a range of data. - unsigned char overwrite = offset; - unsigned long npiv; - - do { - npiv = mas_logical_pivot(mas, pivots, ++overwrite, mt); - } while (npiv < mas->last); - - if (npiv > mas->last) - overwrite--; - - slot_cnt -= (overwrite - offset); - } - if (slot_cnt >= slot_max) // not enough room for new data. - return false; - - if (slot_cnt < mt_min_slots[mt]) // Not enough data for a node. - return false; - - // Can use fast path. - new_end = slot_cnt; - // copy data further out on shift right. - if (slot_cnt > end) - return false; - //mas_shift_right(mas, offset, slot_cnt, end); - - if (r_max > mas->last) { - - } - - - if (new_end < end) { // Zero new_end -> end. - if (end == mt_pivots[mt]) - slots[end--] = NULL; - - while(end > new_end) { - slots[end] = NULL; - pivots[end--] = 0; - } - } - - - - -#if 0 - printk("\n"); - shift = slot_cnt - end; - printk("end is %u slot_cnt is %u shift %d\n", end, slot_cnt, shift); - // Check if this is an append operation. - if (offset == end) - return mas_append(mas, slots, pivots, offset, slot_cnt, entry, content); - if (shift < 0) - mas_truncate(mas, slots, pivots, offset, shift, entry, end); - if (shift >= 0) - mas_expand(mas, slots, pivots, offset, shift, entry, end); -#endif - mas_update_gap(mas); - return true; -} -static inline bool mas_medium_store(struct ma_state *mas, void *entry, - unsigned long min, unsigned char end, - void *content) -{ - enum maple_type mt = mte_node_type(mas->node); - struct maple_node *node = mte_to_node(mas->node); - void **slots = ma_slots(node, mt); - unsigned long *pivots = ma_pivots(node, mt); - struct maple_node new_node; - void **nslots = ma_slots(&new_node, mt); - unsigned long *npivots = ma_pivots(&new_node, mt); - unsigned char offset = mas_offset(mas); //may have changed on extend null. - unsigned char size, noffset = offset; - - memset(&new_node, 0, sizeof(struct maple_node)); - if (offset) { - memcpy(nslots, slots, sizeof(void*) * offset); - memcpy(npivots, pivots, sizeof(unsigned long) * offset); - - } - - if (min != mas->index) - noffset++; - - nslots[noffset] = entry; - npivots[noffset++] = mas->last; - - if (mas->last < pivots[offset]) { - nslots[noffset] = content; - npivots[noffset++] = pivots[offset]; - } - - while (offset < mt_slots[mt] && pivots[offset] <= mas->last) { - offset++; - } - - size = mt_slots[mt] - 1 - offset; - memcpy(nslots + noffset, slots + offset, sizeof(void*) * size); - size = min(size, (unsigned char) (mt_pivots[mt] - 1)); - memcpy(npivots + noffset, pivots + offset, sizeof(unsigned long) * size); - memcpy(node, &new_node, sizeof(struct maple_node)); - return true; -} - -#endif static inline bool mas_fast_store(struct ma_state *mas, void *entry, unsigned long min, unsigned long max, unsigned char end, void *content) -- 2.50.1