]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
move mas_wr_rebalance_calc()
authorLiam R. Howlett <Liam.Howlett@oracle.com>
Tue, 6 May 2025 15:48:41 +0000 (11:48 -0400)
committerLiam R. Howlett <Liam.Howlett@oracle.com>
Tue, 6 May 2025 15:48:41 +0000 (11:48 -0400)
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
lib/maple_tree.c

index 8aa08127aa6477e375eaee3e66200a498755ea45..c0d3f3254ccf66dcf8fef9bb60e0ad9c7cefe028 100644 (file)
@@ -3502,38 +3502,6 @@ static __always_inline unsigned char mas_wr_new_end(struct ma_wr_state *wr_mas)
        return new_end;
 }
 
-/*
- * mas_wr_rebalance_calc() - Try to calculate a rebalance that will work
- * @data_size: The total data to be written
- * @mt: The maple node types splitting the data
- *
- * Returns: 0 on failure, the split location otherwise.
- */
-static inline
-unsigned char mas_wr_rebalance_calc(unsigned char data_size,
-               enum maple_type mt)
-{
-       unsigned char space, split;
-       unsigned char node_size, node_min;
-
-       node_min = mt_min_slots[mt];
-       node_size = mt_slots[mt];
-
-       space = node_size * 2 - 2;
-       /* Greedy rebalance */
-       if (space <= data_size)
-               return 0;
-
-       split = node_size - 2;
-       if (data_size - split >= node_size)
-               return 0;
-
-       if (data_size - split <= node_min)
-               split = (data_size + 2) / 2;
-
-       return split;
-}
-
 static inline
 void mas_wr_ascend_init(struct ma_state *mas, struct ma_node_info *ni)
 {
@@ -3791,6 +3759,37 @@ static void mt_wr_split_data(struct ma_node_info *src,
        } while (src->offset <= src->end);
 }
 
+/*
+ * mas_wr_rebalance_calc() - Try to calculate a rebalance that will work
+ * @data_size: The total data to be written
+ * @mt: The maple node types splitting the data
+ *
+ * Returns: 0 on failure, the split location otherwise.
+ */
+static inline
+unsigned char mas_wr_rebalance_calc(unsigned char data_size,
+               enum maple_type mt)
+{
+       unsigned char space, split;
+       unsigned char node_size, node_min;
+
+       node_min = mt_min_slots[mt];
+       node_size = mt_slots[mt];
+
+       space = node_size * 2 - 2;
+       /* Greedy rebalance */
+       if (space <= data_size)
+               return 0;
+
+       split = node_size - 2;
+       if (data_size - split >= node_size)
+               return 0;
+
+       if (data_size - split <= node_min)
+               split = (data_size + 2) / 2;
+
+       return split;
+}
 
 static inline
 bool can_rebalance_right(struct ma_state *tmp_mas, struct ma_node_info *parent,