]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
maple_tree: Fix validate on empty tree and some compile issue. crap.
authorLiam R. Howlett <Liam.Howlett@Oracle.com>
Mon, 28 Sep 2020 19:26:07 +0000 (15:26 -0400)
committerLiam R. Howlett <Liam.Howlett@Oracle.com>
Tue, 5 Jan 2021 17:30:30 +0000 (12:30 -0500)
Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
lib/maple_tree.c

index f1d9ae6b6f2a13ac25f73f6518e0f33a10937a0a..e1f9b358a90302d4f7be975c067cadba500312c3 100644 (file)
@@ -642,7 +642,7 @@ static inline struct maple_enode *mas_get_slot(struct ma_state *mas,
 static inline void *mas_root(struct ma_state *mas)
 {
        if (mt_in_rcu(mas->tree))
-               return rcu_dereference(mas->tree->ma_root)
+               return rcu_dereference(mas->tree->ma_root);
 
        return mas->tree->ma_root;
 }
@@ -1031,19 +1031,19 @@ static inline struct maple_enode *mas_start(struct ma_state *mas)
                mas->max = ULONG_MAX;
                mas->depth = 0;
                mas_set_offset(mas, 0);
-               if (!mas->tree->ma_root) // empty tree.
+               if (!mas_root(mas)) // empty tree.
                        goto done;
 
-               root = mte_safe_root(mas->tree->ma_root);
+               root = mte_safe_root(mas_root(mas));
 
-               if (xa_is_node(mas->tree->ma_root)) {
+               if (xa_is_node(mas_root(mas))) {
                        mas->node = root;
                } else {
                        // Single entry tree.
                        if (mas->index > 0)
                                goto done;
 
-                       entry = mas->tree->ma_root;
+                       entry = mas_root(mas);
                        mas->node = MAS_ROOT;
                        mas_set_offset(mas, MAPLE_NODE_SLOTS);
                }
@@ -1321,7 +1321,7 @@ static inline void mas_replace(struct ma_state *mas, bool advanced)
        void **slots;
 
        if (mte_is_root(mas->node)) {
-               prev = mas->tree->ma_root;
+               prev = mas_root_locked(mas);
        } else {
                enum maple_type ptype = mas_parent_enum(mas, mas->node);
 
@@ -2731,10 +2731,10 @@ static inline int ma_root_ptr(struct ma_state *mas, void *entry,
 {
        int ret = 1;
 
-       if (xa_is_node(mas->tree->ma_root))
+       if (xa_is_node(mas_root(mas)))
                return 0;
 
-       if (mas->tree->ma_root && mas->last == 0) {
+       if (mas_root(mas) && mas->last == 0) {
                contents = mas_root_locked(mas);
                if (!overwrite)
                        goto exists;
@@ -5237,7 +5237,7 @@ void mt_validate_nulls(struct maple_tree *mt)
        do {
                entry = slots[offset];
                if (!last && !entry) {
-                       printk("Sequential nulls end at %p[%u]\n",
+                       pr_err("Sequential nulls end at %p[%u]\n",
                                mas_mn(&mas), offset);
                }
                MT_BUG_ON(mt, !last && !entry);
@@ -5267,6 +5267,9 @@ void mt_validate(struct maple_tree *mt)
        MA_STATE(mas, mt, 0, 0);
        rcu_read_lock();
        mas_start(&mas);
+       if (!mas_searchable(&mas))
+               goto done;
+
        mas_first_entry(&mas, ULONG_MAX);
        while (!mas_is_none(&mas)) {
                if (!mte_is_root(mas.node)) {
@@ -5287,6 +5290,7 @@ void mt_validate(struct maple_tree *mt)
                mas_dfs_postorder(&mas, ULONG_MAX);
        }
        mt_validate_nulls(mt);
+done:
        rcu_read_unlock();
 
 }