From: Liam R. Howlett Date: Mon, 28 Feb 2022 14:58:21 +0000 (-0500) Subject: Fix compile warnings X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=b5af81f48eb3f0ac1a1bc779dcac2322d09178a1;p=users%2Fjedix%2Flinux-maple.git Fix compile warnings Signed-off-by: Liam R. Howlett --- diff --git a/include/linux/maple_tree.h b/include/linux/maple_tree.h index e808794e06a5..9737e5ca9d26 100644 --- a/include/linux/maple_tree.h +++ b/include/linux/maple_tree.h @@ -316,6 +316,12 @@ int mtree_insert(struct maple_tree *mt, unsigned long index, void *entry, gfp_t gfp); int mtree_insert_range(struct maple_tree *mt, unsigned long first, unsigned long last, void *entry, gfp_t gfp); +int mtree_alloc_range(struct maple_tree *mt, unsigned long *startp, + void *entry, unsigned long size, unsigned long min, + unsigned long max, gfp_t gfp); +int mtree_alloc_rrange(struct maple_tree *mt, unsigned long *startp, + void *entry, unsigned long size, unsigned long min, + unsigned long max, gfp_t gfp); int mtree_store_range(struct maple_tree *mt, unsigned long first, unsigned long last, void *entry, gfp_t gfp); diff --git a/lib/maple_tree.c b/lib/maple_tree.c index d782e747771b..a7737fe7f1e0 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -464,16 +464,19 @@ void mte_set_parent(struct maple_enode *enode, const struct maple_enode *parent, unsigned long type; enum maple_type p_type = mte_node_type(parent); + BUG_ON(p_type == maple_dense); + BUG_ON(p_type == maple_leaf_64); + switch(p_type) { case maple_range_64: case maple_arange_64: shift = MAPLE_PARENT_SLOT_SHIFT; type = MAPLE_PARENT_RANGE64; break; + default: case maple_dense: case maple_leaf_64: shift = type = 0; - BUG_ON(1); break; } @@ -828,20 +831,6 @@ static inline void *mas_slot(struct ma_state *mas, void __rcu **slots, return mt_slot(mas->tree, slots, offset); } -/* - * mas_get_slot() - Get the entry in the maple state node stored at @offset. - * @mas: The maple state - * @offset: The offset into the slot array to fetch. - * - * Return: The entry stored at @offset. - */ -static inline struct maple_enode *mas_get_slot(struct ma_state *mas, - unsigned char offset) -{ - return mas_slot(mas, ma_slots(mas_mn(mas), mte_node_type(mas->node)), - offset); -} - /* * mas_root() - Get the maple tree root. * @mas: The maple state. @@ -4585,93 +4574,6 @@ retry: } -/* - * mas_dead_node() - Check if the maple state is pointing to a dead node. - * @mas: The maple state - * @index: The index to restore in @mas. - * - * Return: 1 if @mas has been reset to MAS_START, 0 otherwise. - */ -static inline int mas_dead_node(struct ma_state *mas, unsigned long index) -{ - if (unlikely(!mas_searchable(mas) || mas_is_start(mas))) - return 0; - - if (likely(!mte_dead_node(mas->node))) - return 0; - - mas_rewalk(mas, index); - return 1; -} - -/* - * mas_first_entry() - Go the first leaf and find the first entry. - * @mas: the maple state. - * @limit: the maximum index to check. - * @*r_start: Pointer to set to the range start. - * - * Sets mas->offset to the offset of the entry, r_start to the range minimum. - * - * Return: The first entry or MAS_NONE. - */ -static inline void *mas_first_entry(struct ma_state *mas, struct maple_node *mn, - unsigned long limit, enum maple_type mt) -{ - unsigned long max; - unsigned long *pivots; - void __rcu **slots; - void *entry = NULL; - - mas->index = mas->min; - if (mas->index > limit) - goto none; - - max = mas->max; - mas->offset = 0; - while (likely(!ma_is_leaf(mt))) { - slots = ma_slots(mn, mt); - pivots = ma_pivots(mn, mt); - max = pivots[0]; - entry = mas_slot(mas, slots, 0); - if (unlikely(ma_dead_node(mn))) - return NULL; - mas->node = entry; - mn = mas_mn(mas); - mt = mte_node_type(mas->node); - } - - mas->max = max; - slots = ma_slots(mn, mt); - entry = mas_slot(mas, slots, 0); - if (unlikely(ma_dead_node(mn))) - return NULL; - - /* Slot 0 or 1 must be set */ - if (mas->index > limit) - goto none; - - if(likely(entry)) - return entry; - - pivots = ma_pivots(mn, mt); - mas->index = pivots[0] + 1; - mas->offset = 1; - entry = mas_slot(mas, slots, 1); - if (unlikely(ma_dead_node(mn))) - return NULL; - - if (mas->index > limit) - goto none; - - if(likely(entry)) - return entry; - -none: - if (likely(!ma_dead_node(mn))) - mas->node = MAS_NONE; - return NULL; -} - /* * mas_next_entry() - Internal function to get the next entry. * @mas: The maple state @@ -5543,7 +5445,7 @@ static inline void mte_destroy_walk(struct maple_enode *enode, } } -void mas_wr_store_setup(struct ma_wr_state *wr_mas) +static void mas_wr_store_setup(struct ma_wr_state *wr_mas) { if (!mas_is_start(wr_mas->mas)) { if (mas_is_none(wr_mas->mas)) @@ -6205,6 +6107,7 @@ retry: mtree_unlock(mt); return ret; } +EXPORT_SYMBOL(mtree_alloc_range); int mtree_alloc_rrange(struct maple_tree *mt, unsigned long *startp, void *entry, unsigned long size, unsigned long min, @@ -6237,6 +6140,7 @@ retry: mtree_unlock(mt); return ret; } +EXPORT_SYMBOL(mtree_alloc_rrange); /** * mtree_erase() - Find an index and erase the entire range. @@ -6476,8 +6380,76 @@ static void mas_bfs_preorder(struct ma_state *mas) } #endif /* CONFIG_MAPLE_EXTRAS */ +#endif /* CONFIG_MAPLE_SEARCH */ -#endif +/* + * mas_first_entry() - Go the first leaf and find the first entry. + * @mas: the maple state. + * @limit: the maximum index to check. + * @*r_start: Pointer to set to the range start. + * + * Sets mas->offset to the offset of the entry, r_start to the range minimum. + * + * Return: The first entry or MAS_NONE. + */ +static inline void *mas_first_entry(struct ma_state *mas, struct maple_node *mn, + unsigned long limit, enum maple_type mt) + +{ + unsigned long max; + unsigned long *pivots; + void __rcu **slots; + void *entry = NULL; + + mas->index = mas->min; + if (mas->index > limit) + goto none; + + max = mas->max; + mas->offset = 0; + while (likely(!ma_is_leaf(mt))) { + slots = ma_slots(mn, mt); + pivots = ma_pivots(mn, mt); + max = pivots[0]; + entry = mas_slot(mas, slots, 0); + if (unlikely(ma_dead_node(mn))) + return NULL; + mas->node = entry; + mn = mas_mn(mas); + mt = mte_node_type(mas->node); + } + + mas->max = max; + slots = ma_slots(mn, mt); + entry = mas_slot(mas, slots, 0); + if (unlikely(ma_dead_node(mn))) + return NULL; + + /* Slot 0 or 1 must be set */ + if (mas->index > limit) + goto none; + + if(likely(entry)) + return entry; + + pivots = ma_pivots(mn, mt); + mas->index = pivots[0] + 1; + mas->offset = 1; + entry = mas_slot(mas, slots, 1); + if (unlikely(ma_dead_node(mn))) + return NULL; + + if (mas->index > limit) + goto none; + + if(likely(entry)) + return entry; + +none: + if (likely(!ma_dead_node(mn))) + mas->node = MAS_NONE; + return NULL; +} /* Depth first search, post-order */ static void mas_dfs_postorder(struct ma_state *mas, unsigned long max) @@ -6666,6 +6638,20 @@ void mt_dump(const struct maple_tree *mt) mt_dump_node(mt, entry, 0, mt_max[mte_node_type(entry)], 0); } +/* + * mas_get_slot() - Get the entry in the maple state node stored at @offset. + * @mas: The maple state + * @offset: The offset into the slot array to fetch. + * + * Return: The entry stored at @offset. + */ +static inline struct maple_enode *mas_get_slot(struct ma_state *mas, + unsigned char offset) +{ + return mas_slot(mas, ma_slots(mas_mn(mas), mte_node_type(mas->node)), + offset); +} + /* * Calculate the maximum gap in a node and check if that's what is reported in * the parent (unless root).