diff options
author | Matthew Wilcox <willy@infradead.org> | 2017-11-07 16:30:10 -0500 |
---|---|---|
committer | Matthew Wilcox <willy@infradead.org> | 2018-10-21 10:45:53 -0400 |
commit | f8d5d0cc145cc21bfc56ef807dc28102aebbf228 (patch) | |
tree | 0fcba575e83fb02fd2cb49df1ce1cc55bcd927d3 /lib/xarray.c | |
parent | 02c02bf12c5d838603eed44195d3e91f094e2ab2 (diff) |
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>
Diffstat (limited to 'lib/xarray.c')
-rw-r--r-- | lib/xarray.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/lib/xarray.c b/lib/xarray.c new file mode 100644 index 000000000000..862f4c64c754 --- /dev/null +++ b/lib/xarray.c | |||
@@ -0,0 +1,44 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0+ | ||
2 | /* | ||
3 | * XArray implementation | ||
4 | * Copyright (c) 2017 Microsoft Corporation | ||
5 | * Author: Matthew Wilcox <willy@infradead.org> | ||
6 | */ | ||
7 | |||
8 | #include <linux/export.h> | ||
9 | #include <linux/xarray.h> | ||
10 | |||
11 | /* | ||
12 | * Coding conventions in this file: | ||
13 | * | ||
14 | * @xa is used to refer to the entire xarray. | ||
15 | * @xas is the 'xarray operation state'. It may be either a pointer to | ||
16 | * an xa_state, or an xa_state stored on the stack. This is an unfortunate | ||
17 | * ambiguity. | ||
18 | * @index is the index of the entry being operated on | ||
19 | * @mark is an xa_mark_t; a small number indicating one of the mark bits. | ||
20 | * @node refers to an xa_node; usually the primary one being operated on by | ||
21 | * this function. | ||
22 | * @offset is the index into the slots array inside an xa_node. | ||
23 | * @parent refers to the @xa_node closer to the head than @node. | ||
24 | * @entry refers to something stored in a slot in the xarray | ||
25 | */ | ||
26 | |||
27 | /** | ||
28 | * xa_init_flags() - Initialise an empty XArray with flags. | ||
29 | * @xa: XArray. | ||
30 | * @flags: XA_FLAG values. | ||
31 | * | ||
32 | * If you need to initialise an XArray with special flags (eg you need | ||
33 | * to take the lock from interrupt context), use this function instead | ||
34 | * of xa_init(). | ||
35 | * | ||
36 | * Context: Any context. | ||
37 | */ | ||
38 | void xa_init_flags(struct xarray *xa, gfp_t flags) | ||
39 | { | ||
40 | spin_lock_init(&xa->xa_lock); | ||
41 | xa->xa_flags = flags; | ||
42 | xa->xa_head = NULL; | ||
43 | } | ||
44 | EXPORT_SYMBOL(xa_init_flags); | ||