mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-06-17 20:25:19 +00:00
xarray: Add definition of struct xarray
This is a direct replacement for struct radix_tree_root. Some of the struct members have changed name; convert those, and use a #define so that radix_tree users continue to work without change. Signed-off-by: Matthew Wilcox <willy@infradead.org> Reviewed-by: Josef Bacik <jbacik@fb.com>
This commit is contained in:
parent
02c02bf12c
commit
f8d5d0cc14
12 changed files with 181 additions and 68 deletions
44
lib/xarray.c
Normal file
44
lib/xarray.c
Normal file
|
@ -0,0 +1,44 @@
|
|||
// SPDX-License-Identifier: GPL-2.0+
|
||||
/*
|
||||
* XArray implementation
|
||||
* Copyright (c) 2017 Microsoft Corporation
|
||||
* Author: Matthew Wilcox <willy@infradead.org>
|
||||
*/
|
||||
|
||||
#include <linux/export.h>
|
||||
#include <linux/xarray.h>
|
||||
|
||||
/*
|
||||
* Coding conventions in this file:
|
||||
*
|
||||
* @xa is used to refer to the entire xarray.
|
||||
* @xas is the 'xarray operation state'. It may be either a pointer to
|
||||
* an xa_state, or an xa_state stored on the stack. This is an unfortunate
|
||||
* ambiguity.
|
||||
* @index is the index of the entry being operated on
|
||||
* @mark is an xa_mark_t; a small number indicating one of the mark bits.
|
||||
* @node refers to an xa_node; usually the primary one being operated on by
|
||||
* this function.
|
||||
* @offset is the index into the slots array inside an xa_node.
|
||||
* @parent refers to the @xa_node closer to the head than @node.
|
||||
* @entry refers to something stored in a slot in the xarray
|
||||
*/
|
||||
|
||||
/**
|
||||
* xa_init_flags() - Initialise an empty XArray with flags.
|
||||
* @xa: XArray.
|
||||
* @flags: XA_FLAG values.
|
||||
*
|
||||
* If you need to initialise an XArray with special flags (eg you need
|
||||
* to take the lock from interrupt context), use this function instead
|
||||
* of xa_init().
|
||||
*
|
||||
* Context: Any context.
|
||||
*/
|
||||
void xa_init_flags(struct xarray *xa, gfp_t flags)
|
||||
{
|
||||
spin_lock_init(&xa->xa_lock);
|
||||
xa->xa_flags = flags;
|
||||
xa->xa_head = NULL;
|
||||
}
|
||||
EXPORT_SYMBOL(xa_init_flags);
|
Loading…
Add table
Add a link
Reference in a new issue