lib/xarray: introduce a new helper xas_get_order
authorKairui Song <kasong@tencent.com>
Mon, 15 Apr 2024 17:18:55 +0000 (01:18 +0800)
committerAndrew Morton <akpm@linux-foundation.org>
Fri, 26 Apr 2024 03:56:09 +0000 (20:56 -0700)
commita4864671ca0bf51c8e78242951741df52c06766f
treef335864cbcd5b7ea0525614f09ee6ab54c0cc144
parentb2ebcf9d3d5a0108f640d8c8200ece8848045725
lib/xarray: introduce a new helper xas_get_order

It can be used after xas_load to check the order of loaded entries.
Compared to xa_get_order, it saves an XA_STATE and avoid a rewalk.

Added new test for xas_get_order, to make the test work, we have to export
xas_get_order with EXPORT_SYMBOL_GPL.

Also fix a sparse warning by checking the slot value with xa_entry instead
of accessing it directly, as suggested by Matthew Wilcox.

[kasong@tencent.com: simplify comment, sparse warning fix, per Matthew Wilcox]
Link: https://lkml.kernel.org/r/20240416071722.45997-4-ryncsn@gmail.com
Link: https://lkml.kernel.org/r/20240415171857.19244-4-ryncsn@gmail.com
Signed-off-by: Kairui Song <kasong@tencent.com>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
include/linux/xarray.h
lib/test_xarray.c
lib/xarray.c