maple-tree: Add __mt_destroy()
authorMatthew Wilcox (Oracle) <willy@infradead.org>
Wed, 20 Oct 2021 19:19:59 +0000 (15:19 -0400)
committerMatthew Wilcox (Oracle) <willy@infradead.org>
Wed, 20 Oct 2021 19:19:59 +0000 (15:19 -0400)
Separate out the guts of mtree_destroy() into a function which assumes
the lock is held.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
include/linux/maple_tree.h
lib/maple_tree.c

index 23b8b6dc658eca9e6364205525d83b534017c247..19276546faba5abac458feebb3d741719cc354c9 100644 (file)
@@ -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.
index 20ed92e86a55b66c42c62d6696865b3aa9613f4a..bac59712774c7a2a66ea0a987e1d1bde1db85686 100644 (file)
@@ -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);