FROMLIST: BACKPORT: maple_tree: Move mas_wr_end_piv() below mas_wr_extend_null()

Relocate it and call mas_wr_extend_null() from within mas_wr_end_piv().
Extending the NULL may affect the end pivot value so call
mas_wr_endtend_null() from within mas_wr_end_piv() to keep it all
together.

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>

Link: https://lore.kernel.org/lkml/20230601021605.2823123-12-Liam.Howlett@oracle.com/
[surenb: moved additional wr_mas->end_piv assignment missing in later
kernel versions]

Bug: 274059236
Change-Id: I55c5843273e7a679aef918e66d4b4ed034d493da
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
This commit is contained in:
Liam R. Howlett 2023-05-31 22:16:02 -04:00 committed by Suren Baghdasaryan
parent aede79b81e
commit b6734cb2ce

View file

@ -4284,16 +4284,6 @@ done:
return true;
}
static inline void mas_wr_end_piv(struct ma_wr_state *wr_mas)
{
while ((wr_mas->mas->last > wr_mas->end_piv) &&
(wr_mas->offset_end < wr_mas->node_end))
wr_mas->end_piv = wr_mas->pivots[++wr_mas->offset_end];
if (wr_mas->mas->last > wr_mas->end_piv)
wr_mas->end_piv = wr_mas->mas->max;
}
static inline void mas_wr_extend_null(struct ma_wr_state *wr_mas)
{
struct ma_state *mas = wr_mas->mas;
@ -4328,6 +4318,21 @@ static inline void mas_wr_extend_null(struct ma_wr_state *wr_mas)
}
}
static inline void mas_wr_end_piv(struct ma_wr_state *wr_mas)
{
wr_mas->end_piv = wr_mas->r_max;
while ((wr_mas->mas->last > wr_mas->end_piv) &&
(wr_mas->offset_end < wr_mas->node_end))
wr_mas->end_piv = wr_mas->pivots[++wr_mas->offset_end];
if (wr_mas->mas->last > wr_mas->end_piv)
wr_mas->end_piv = wr_mas->mas->max;
if (!wr_mas->entry)
mas_wr_extend_null(wr_mas);
}
static inline bool mas_wr_append(struct ma_wr_state *wr_mas)
{
unsigned char end = wr_mas->node_end;
@ -4447,12 +4452,8 @@ static inline void *mas_wr_store_entry(struct ma_wr_state *wr_mas)
}
/* At this point, we are at the leaf node that needs to be altered. */
wr_mas->end_piv = wr_mas->r_max;
mas_wr_end_piv(wr_mas);
if (!wr_mas->entry)
mas_wr_extend_null(wr_mas);
/* New root for a single pointer */
if (unlikely(!mas->index && mas->last == ULONG_MAX)) {
mas_new_root(mas, wr_mas->entry);