From: Matthew Wilcox (Oracle) Date: Wed, 20 Oct 2021 19:19:59 +0000 (-0400) Subject: maple-tree: Add __mt_destroy() X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=bf65bb76d27f9904eb7a4474e0080945a56ffd81;p=users%2Fwilly%2Flinux.git maple-tree: Add __mt_destroy() Separate out the guts of mtree_destroy() into a function which assumes the lock is held. Signed-off-by: Matthew Wilcox (Oracle) --- diff --git a/include/linux/maple_tree.h b/include/linux/maple_tree.h index 23b8b6dc658e..19276546faba 100644 --- a/include/linux/maple_tree.h +++ b/include/linux/maple_tree.h @@ -238,6 +238,7 @@ int mtree_store_range(struct maple_tree *mt, unsigned long first, unsigned long last, void *entry, gfp_t gfp); int mtree_store(struct maple_tree *mt, unsigned long index, void *entry, gfp_t gfp); +void __mt_destroy(struct maple_tree *mt); /** * mtree_empty() - Determine if a tree has any present entries. diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 20ed92e86a55..bac59712774c 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -6187,6 +6187,18 @@ void *mtree_erase(struct maple_tree *mt, unsigned long index) } EXPORT_SYMBOL(mtree_erase); +void __mt_destroy(struct maple_tree *mt) +{ + void *root = mt_root_locked(mt); + + rcu_assign_pointer(mt->ma_root, NULL); + if (xa_is_node(root)) + mte_destroy_walk(root, mt); + + mt->ma_flags = 0; +} +EXPORT_SYMBOL_GPL(__mt_destroy); + /* * mtree_destroy() - Destroy a maple tree * @mt: The maple tree @@ -6195,15 +6207,8 @@ EXPORT_SYMBOL(mtree_erase); */ void mtree_destroy(struct maple_tree *mt) { - void *root; - mtree_lock(mt); - root = mt_root_locked(mt); - rcu_assign_pointer(mt->ma_root, NULL); - if (xa_is_node(root)) - mte_destroy_walk(root, mt); - - mt->ma_flags = 0; + __mt_destroy(mt); mtree_unlock(mt); } EXPORT_SYMBOL(mtree_destroy);