[PATCH v2 0/2] Fix mas_skip_node() for mas_empty_area()

From: Liam R. Howlett
Date: Tue Mar 07 2023 - 13:09:33 EST


Andrew, this should replace these patches in mm-hotfixes-unstable:
400922513f30 ("maple_tree: fix mas_skip_node() end slot detection")
4d4ec28ef3a4 ("test_maple_tree: add more testing for mas_empty_area()")

mas_empty_area() was incorrectly returning an error when there was room.
The issue was tracked down to mas_skip_node() using the incorrect
end-of-slot count. Instead of using the nodes hard limit, the limit of
data should be used.

mas_skip_node() was also setting the min and max to that of the child
node, which was unnecessary. Within these limits being set, there was
also a bug that corrupted the maple state's max if the offset was set to
the maximum node pivot. The bug was without consequence unless there
was a sufficient gap in the next child node which would cause an error
to be returned.

This patch set fixes these errors by removing the limit setting from
mas_skip_node() and uses the mas_data_end() for slot limits, and adds
tests for all failures discovered.

Liam R. Howlett (2):
maple_tree: Fix mas_skip_node() end slot detection
test_maple_tree: Add more testing for mas_empty_area()

lib/maple_tree.c | 24 +++++-----------------
lib/test_maple_tree.c | 48 +++++++++++++++++++++++++++++++++++++++++++
2 files changed, 53 insertions(+), 19 deletions(-)

--
2.39.2