]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
mas_entry_cnt() rename and cleanup
authorLiam R. Howlett <Liam.Howlett@Oracle.com>
Fri, 9 Oct 2020 19:00:28 +0000 (15:00 -0400)
committerLiam R. Howlett <Liam.Howlett@Oracle.com>
Fri, 30 Oct 2020 19:12:57 +0000 (15:12 -0400)
Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
include/linux/maple_tree.h
lib/maple_tree.c

index 0810c7427cb49e6fc78a554103504a2c8000789d..eecf046cab0582563b745fd40df8b666bc517f99 100644 (file)
@@ -395,7 +395,7 @@ static inline void mt_set_in_rcu(struct maple_tree *mt)
        mtree_unlock(mt);
 }
 
-int mas_entry_cnt(struct ma_state *mas, unsigned long nr_leaves);
+int mas_entry_count(struct ma_state *mas, unsigned long nr_leaves);
 
 void *mt_find(struct maple_tree *mt, unsigned long *index, unsigned long max);
 void *_mt_find(struct maple_tree *mt, unsigned long *index, unsigned long max,
index 9a20236d346de8276a9d03f7ed1cab7256fae180..25fe27927fa321880c281d7ce4c805e7f7284a73 100644 (file)
@@ -18,6 +18,8 @@
 #include <trace/events/maple_tree.h>
 
 #define MA_ROOT_PARENT 1
+#define MAPLE_NODE_MAX MAPLE_NODE_MASK
+
 #define ma_parent_ptr(x) ((struct maple_pnode *)(x))
 #define ma_mnode_ptr(x) ((struct maple_node *)(x))
 #define ma_enode_ptr(x) ((struct maple_enode *)(x))
@@ -993,15 +995,16 @@ static inline struct maple_node *mas_node_cnt(struct ma_state *mas, int count)
        return mas->alloc;
 }
 
-int mas_entry_cnt(struct ma_state *mas, unsigned long nr_entries) {
+int mas_entry_count(struct ma_state *mas, unsigned long nr_entries) {
        int nonleaf_cap = MAPLE_ARANGE64_SLOTS - 1;
-       int nr_leaves;
+       int nr_nodes;
 
        if (!mt_is_alloc(mas->tree))
            nonleaf_cap = MAPLE_RANGE64_SLOTS - 1;
 
-       nr_leaves = DIV_ROUND_UP(nr_entries, MAPLE_RANGE64_SLOTS);
-       mas_node_cnt(mas, nr_leaves +  DIV_ROUND_UP(nr_leaves, nonleaf_cap));
+       nr_nodes = DIV_ROUND_UP(nr_entries, MAPLE_RANGE64_SLOTS); // leaves
+       nr_nodes += DIV_ROUND_UP(nr_nodes, nonleaf_cap);
+       mas_node_cnt(mas, min(nr_nodes, (int)MAPLE_NODE_MAX));
        if (!mas_is_err(mas))
                return 0;
        return xa_err(mas->node);