From: Liam R. Howlett <Liam.Howlett@Oracle.com>
Date: Tue, 17 Dec 2024 20:18:17 +0000 (-0500)
Subject: maple_tree: Clean up sheaf
X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=a3231377d56e9a4d861d7d7327f6bbb83dd97de5;p=users%2Fjedix%2Flinux-maple.git

maple_tree: Clean up sheaf

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
---

diff --git a/lib/maple_tree.c b/lib/maple_tree.c
index 9d74b78683f0..fa3bf8da8cb9 100644
--- a/lib/maple_tree.c
+++ b/lib/maple_tree.c
@@ -198,6 +198,21 @@ static void mt_free_rcu(struct rcu_head *head)
 	kmem_cache_free(maple_node_cache, node);
 }
 
+static void mt_return_sheaf(struct slab_sheaf *sheaf)
+{
+	kmem_cache_return_sheaf(maple_node_cache, GFP_KERNEL, sheaf);
+}
+
+static struct slab_sheaf *mt_get_sheaf(gfp_t gfp, int count)
+{
+	return kmem_cache_prefill_sheaf(maple_node_cache, gfp, count);
+}
+
+static int mt_refill_sheaf(gfp_t gfp, struct slab_sheaf *sheaf)
+{
+	return kmem_cache_refill_sheaf(maple_node_cache, gfp, sheaf);
+}
+
 /*
  * ma_free_rcu() - Use rcu callback to free a maple node
  * @node: The node to free
@@ -1148,16 +1163,14 @@ use_sheaf:
 			return;
 		}
 
-		if (kmem_cache_refill_sheaf(maple_node_cache, gfp, mas->sheaf))
+		if (mt_refill_sheaf(gfp, mas->sheaf))
 			goto error;
 
 		mas->node_request = 0;
 		return;
 	}
 
-	mas->sheaf = kmem_cache_prefill_sheaf(maple_node_cache, gfp,
-					      mas->node_request);
-
+	mas->sheaf = mt_get_sheaf(gfp, mas->node_request);
 	if (likely(mas->sheaf)) {
 		mas->node_request = 0;
 		return;
@@ -1171,8 +1184,7 @@ static inline void mas_empty_nodes(struct ma_state *mas)
 {
 	mas->node_request = 0;
 	if (mas->sheaf) {
-		kmem_cache_return_sheaf(maple_node_cache, GFP_KERNEL,
-					mas->sheaf);
+		mt_return_sheaf(mas->sheaf);
 		mas->sheaf = NULL;
 	}