summaryrefslogtreecommitdiffstats
path: root/lib/radix-tree.c
diff options
context:
space:
mode:
authorMatthew Wilcox <mawilcox@microsoft.com>2017-01-16 23:10:21 +0100
committerMatthew Wilcox <mawilcox@microsoft.com>2017-02-14 03:44:05 +0100
commitd58275bc96ae933b1b3888af80920dd6b020c505 (patch)
treee1acf252dc43eeb1d65e4f715b0a1d52b1b4af09 /lib/radix-tree.c
parentradix-tree: Chain preallocated nodes through ->parent (diff)
downloadlinux-d58275bc96ae933b1b3888af80920dd6b020c505.tar.xz
linux-d58275bc96ae933b1b3888af80920dd6b020c505.zip
radix-tree: Store a pointer to the root in each node
Instead of having this mysterious private_data in each radix_tree_node, store a pointer to the root, which can be useful for debugging. This also relieves the mm code from the duty of updating it. Acked-by: Johannes Weiner <hannes@cmpxchg.org> Signed-off-by: Matthew Wilcox <mawilcox@microsoft.com>
Diffstat (limited to 'lib/radix-tree.c')
-rw-r--r--lib/radix-tree.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/lib/radix-tree.c b/lib/radix-tree.c
index 66c71312c381..dcb9a2329e65 100644
--- a/lib/radix-tree.c
+++ b/lib/radix-tree.c
@@ -374,6 +374,7 @@ static void ida_dump(struct ida *ida)
*/
static struct radix_tree_node *
radix_tree_node_alloc(gfp_t gfp_mask, struct radix_tree_node *parent,
+ struct radix_tree_root *root,
unsigned int shift, unsigned int offset,
unsigned int count, unsigned int exceptional)
{
@@ -419,11 +420,12 @@ radix_tree_node_alloc(gfp_t gfp_mask, struct radix_tree_node *parent,
out:
BUG_ON(radix_tree_is_internal_node(ret));
if (ret) {
- ret->parent = parent;
ret->shift = shift;
ret->offset = offset;
ret->count = count;
ret->exceptional = exceptional;
+ ret->parent = parent;
+ ret->root = root;
}
return ret;
}
@@ -631,7 +633,7 @@ static int radix_tree_extend(struct radix_tree_root *root, gfp_t gfp,
do {
struct radix_tree_node *node = radix_tree_node_alloc(gfp, NULL,
- shift, 0, 1, 0);
+ root, shift, 0, 1, 0);
if (!node)
return -ENOMEM;
@@ -828,7 +830,7 @@ int __radix_tree_create(struct radix_tree_root *root, unsigned long index,
shift -= RADIX_TREE_MAP_SHIFT;
if (child == NULL) {
/* Have to add a child node. */
- child = radix_tree_node_alloc(gfp, node, shift,
+ child = radix_tree_node_alloc(gfp, node, root, shift,
offset, 0, 0);
if (!child)
return -ENOMEM;
@@ -1330,7 +1332,7 @@ int radix_tree_split(struct radix_tree_root *root, unsigned long index,
for (;;) {
if (node->shift > order) {
- child = radix_tree_node_alloc(gfp, node,
+ child = radix_tree_node_alloc(gfp, node, root,
node->shift - RADIX_TREE_MAP_SHIFT,
offset, 0, 0);
if (!child)
@@ -2152,8 +2154,8 @@ void **idr_get_free(struct radix_tree_root *root,
shift -= RADIX_TREE_MAP_SHIFT;
if (child == NULL) {
/* Have to add a child node. */
- child = radix_tree_node_alloc(gfp, node, shift, offset,
- 0, 0);
+ child = radix_tree_node_alloc(gfp, node, root, shift,
+ offset, 0, 0);
if (!child)
return ERR_PTR(-ENOMEM);
all_tag_set(child, IDR_FREE);