maple_tree: convert mas_prealloc_calc() to take in a maple write state
authorSidhartha Kumar <sidhartha.kumar@oracle.com>
Mon, 7 Apr 2025 18:40:57 +0000 (18:40 +0000)
committerLiam R. Howlett <Liam.Howlett@oracle.com>
Tue, 8 Apr 2025 20:01:05 +0000 (16:01 -0400)
In a subsequent patch, mas_prealloc_calc() will need to access fields only
in the ma_wr_state. Convert the function to take in a ma_wr_state and
modify all callers. There is no functional change.

Reviewed-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
Signed-off-by: Sidhartha Kumar <sidhartha.kumar@oracle.com>
lib/maple_tree.c

index 56e7a00f6f0941bff163091c999a873e4273f071..00a90bc59e6c5914e43782beacc8bb914df9094d 100644 (file)
@@ -4144,13 +4144,14 @@ set_content:
 /**
  * mas_prealloc_calc() - Calculate number of nodes needed for a
  * given store oepration
- * @mas: The maple state
+ * @wr_mas: The maple write state
  * @entry: The entry to store into the tree
  *
  * Return: Number of nodes required for preallocation.
  */
-static inline int mas_prealloc_calc(struct ma_state *mas, void *entry)
+static inline int mas_prealloc_calc(struct ma_wr_state *wr_mas, void *entry)
 {
+       struct ma_state *mas = wr_mas->mas;
        int ret = mas_mt_height(mas) * 3 + 1;
 
        switch (mas->store_type) {
@@ -4247,16 +4248,15 @@ static inline enum store_type mas_wr_store_type(struct ma_wr_state *wr_mas)
  */
 static inline void mas_wr_preallocate(struct ma_wr_state *wr_mas, void *entry)
 {
-       struct ma_state *mas = wr_mas->mas;
        int request;
 
        mas_wr_prealloc_setup(wr_mas);
-       mas->store_type = mas_wr_store_type(wr_mas);
-       request = mas_prealloc_calc(mas, entry);
+       wr_mas->mas->store_type = mas_wr_store_type(wr_mas);
+       request = mas_prealloc_calc(wr_mas, entry);
        if (!request)
                return;
 
-       mas_node_count(mas, request);
+       mas_node_count(wr_mas->mas, request);
 }
 
 /**
@@ -5401,7 +5401,7 @@ void *mas_store(struct ma_state *mas, void *entry)
                return wr_mas.content;
        }
 
-       request = mas_prealloc_calc(mas, entry);
+       request = mas_prealloc_calc(&wr_mas, entry);
        if (!request)
                goto store;
 
@@ -5498,7 +5498,7 @@ int mas_preallocate(struct ma_state *mas, void *entry, gfp_t gfp)
 
        mas_wr_prealloc_setup(&wr_mas);
        mas->store_type = mas_wr_store_type(&wr_mas);
-       request = mas_prealloc_calc(mas, entry);
+       request = mas_prealloc_calc(&wr_mas, entry);
        if (!request)
                return ret;