FROMGIT: maple_tree: clear up index and last setting in single entry tree
When there is a single entry tree (range of 0-0 pointing to an entry), then ensure the limit is either 0-0 or 1-oo, depending on where the user walks. Ensure the correct node setting as well; either MAS_ROOT or MAS_NONE. Link: https://lkml.kernel.org/r/20230518145544.1722059-33-Liam.Howlett@oracle.com Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com> Cc: Peng Zhang <zhangpeng.00@bytedance.com> Cc: David Binderman <dcb314@hotmail.com> Cc: Sergey Senozhatsky <senozhatsky@chromium.org> Cc: Vernon Yang <vernon2gm@gmail.com> Cc: Wei Yang <richard.weiyang@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> (cherry picked from commit c0b1bdd9011ef34b654fe62f2607bff0eb1ef0a8 git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm mm-unstable) Bug: 274059236 Change-Id: I22a41c01e525fde88774b509cd5cbc60f56f6dc5 Signed-off-by: Suren Baghdasaryan <surenb@google.com>
This commit is contained in:
parent
9288f53a31
commit
86d9de0898
1 changed files with 14 additions and 13 deletions
|
|
@ -5050,24 +5050,25 @@ void *mas_walk(struct ma_state *mas)
|
|||
{
|
||||
void *entry;
|
||||
|
||||
if (mas_is_none(mas) || mas_is_paused(mas) || mas_is_ptr(mas))
|
||||
mas->node = MAS_START;
|
||||
retry:
|
||||
entry = mas_state_walk(mas);
|
||||
if (mas_is_start(mas))
|
||||
if (mas_is_start(mas)) {
|
||||
goto retry;
|
||||
|
||||
if (mas_is_ptr(mas)) {
|
||||
if (!mas->index) {
|
||||
mas->last = 0;
|
||||
} else {
|
||||
mas->index = 1;
|
||||
mas->last = ULONG_MAX;
|
||||
}
|
||||
return entry;
|
||||
}
|
||||
|
||||
if (mas_is_none(mas)) {
|
||||
} else if (mas_is_none(mas)) {
|
||||
mas->index = 0;
|
||||
mas->last = ULONG_MAX;
|
||||
} else if (mas_is_ptr(mas)) {
|
||||
if (!mas->index) {
|
||||
mas->last = 0;
|
||||
return entry;
|
||||
}
|
||||
|
||||
mas->index = 1;
|
||||
mas->last = ULONG_MAX;
|
||||
mas->node = MAS_NONE;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return entry;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue