]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
lib/xarray: introduce a new helper xas_get_order
authorKairui Song <kasong@tencent.com>
Tue, 1 Oct 2024 21:06:24 +0000 (05:06 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 4 Oct 2024 14:30:02 +0000 (16:30 +0200)
commit734594d41c8ed87174bbc8f443a935f702de974b
tree68b56ee7285e73a6a6ba5dabe5349e37a1d336d5
parentff3c557fa93e7fcf5891e38fa7285b3c44e994b3
lib/xarray: introduce a new helper xas_get_order

commit a4864671ca0bf51c8e78242951741df52c06766f upstream.

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>
Stable-dep-of: 6758c1128ceb ("mm/filemap: optimize filemap folio adding")
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
include/linux/xarray.h
lib/test_xarray.c
lib/xarray.c