From d23971630e7669bffd77671d1ca6dabbf548262a Mon Sep 17 00:00:00 2001 From: "Liam R. Howlett" Date: Mon, 28 Sep 2020 15:26:07 -0400 Subject: [PATCH] maple_tree: Fix validate on empty tree and some compile issue. crap. Signed-off-by: Liam R. Howlett --- lib/maple_tree.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index f1d9ae6b6f2a..e1f9b358a903 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -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(); } -- 2.50.1