Skip to content

Commit 9bbba56

Browse files
howlettakpm00
authored andcommitted
maple_tree: fix depth tracking in maple_state
It is possible to confuse the depth tracking in the maple state by searching the same node for values. Fix the depth tracking by moving where the depth is incremented closer to where the node changes level. Also change the initial depth setting when using the root node. Link: https://lkml.kernel.org/r/20221107163814.866612-1-Liam.Howlett@oracle.com Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent 1fdbed6 commit 9bbba56

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/maple_tree.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1351,6 +1351,7 @@ static inline struct maple_enode *mas_start(struct ma_state *mas)
13511351
root = mas_root(mas);
13521352
/* Tree with nodes */
13531353
if (likely(xa_is_node(root))) {
1354+
mas->depth = 1;
13541355
mas->node = mte_safe_root(root);
13551356
return NULL;
13561357
}
@@ -3727,7 +3728,6 @@ static bool mas_is_span_wr(struct ma_wr_state *wr_mas)
37273728

37283729
static inline void mas_wr_walk_descend(struct ma_wr_state *wr_mas)
37293730
{
3730-
wr_mas->mas->depth++;
37313731
wr_mas->type = mte_node_type(wr_mas->mas->node);
37323732
mas_wr_node_walk(wr_mas);
37333733
wr_mas->slots = ma_slots(wr_mas->node, wr_mas->type);
@@ -3739,6 +3739,7 @@ static inline void mas_wr_walk_traverse(struct ma_wr_state *wr_mas)
37393739
wr_mas->mas->min = wr_mas->r_min;
37403740
wr_mas->mas->node = wr_mas->content;
37413741
wr_mas->mas->offset = 0;
3742+
wr_mas->mas->depth++;
37423743
}
37433744
/*
37443745
* mas_wr_walk() - Walk the tree for a write.

0 commit comments

Comments
 (0)