summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorMatthew Wilcox <mawilcox@microsoft.com>2017-01-16 17:10:21 -0500
committerMatthew Wilcox <mawilcox@microsoft.com>2017-02-13 21:44:05 -0500
commitd58275bc96ae933b1b3888af80920dd6b020c505 (patch)
treee1acf252dc43eeb1d65e4f715b0a1d52b1b4af09 /lib
parent1293d5c5f54d5118fbb34fc94e01ba02fcd25fc1 (diff)
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')
-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)
374 */ 374 */
375static struct radix_tree_node * 375static struct radix_tree_node *
376radix_tree_node_alloc(gfp_t gfp_mask, struct radix_tree_node *parent, 376radix_tree_node_alloc(gfp_t gfp_mask, struct radix_tree_node *parent,
377 struct radix_tree_root *root,
377 unsigned int shift, unsigned int offset, 378 unsigned int shift, unsigned int offset,
378 unsigned int count, unsigned int exceptional) 379 unsigned int count, unsigned int exceptional)
379{ 380{
@@ -419,11 +420,12 @@ radix_tree_node_alloc(gfp_t gfp_mask, struct radix_tree_node *parent,
419out: 420out:
420 BUG_ON(radix_tree_is_internal_node(ret)); 421 BUG_ON(radix_tree_is_internal_node(ret));
421 if (ret) { 422 if (ret) {
422 ret->parent = parent;
423 ret->shift = shift; 423 ret->shift = shift;
424 ret->offset = offset; 424 ret->offset = offset;
425 ret->count = count; 425 ret->count = count;
426 ret->exceptional = exceptional; 426 ret->exceptional = exceptional;
427 ret->parent = parent;
428 ret->root = root;
427 } 429 }
428 return ret; 430 return ret;
429} 431}
@@ -631,7 +633,7 @@ static int radix_tree_extend(struct radix_tree_root *root, gfp_t gfp,
631 633
632 do { 634 do {
633 struct radix_tree_node *node = radix_tree_node_alloc(gfp, NULL, 635 struct radix_tree_node *node = radix_tree_node_alloc(gfp, NULL,
634 shift, 0, 1, 0); 636 root, shift, 0, 1, 0);
635 if (!node) 637 if (!node)
636 return -ENOMEM; 638 return -ENOMEM;
637 639
@@ -828,7 +830,7 @@ int __radix_tree_create(struct radix_tree_root *root, unsigned long index,
828 shift -= RADIX_TREE_MAP_SHIFT; 830 shift -= RADIX_TREE_MAP_SHIFT;
829 if (child == NULL) { 831 if (child == NULL) {
830 /* Have to add a child node. */ 832 /* Have to add a child node. */
831 child = radix_tree_node_alloc(gfp, node, shift, 833 child = radix_tree_node_alloc(gfp, node, root, shift,
832 offset, 0, 0); 834 offset, 0, 0);
833 if (!child) 835 if (!child)
834 return -ENOMEM; 836 return -ENOMEM;
@@ -1330,7 +1332,7 @@ int radix_tree_split(struct radix_tree_root *root, unsigned long index,
1330 1332
1331 for (;;) { 1333 for (;;) {
1332 if (node->shift > order) { 1334 if (node->shift > order) {
1333 child = radix_tree_node_alloc(gfp, node, 1335 child = radix_tree_node_alloc(gfp, node, root,
1334 node->shift - RADIX_TREE_MAP_SHIFT, 1336 node->shift - RADIX_TREE_MAP_SHIFT,
1335 offset, 0, 0); 1337 offset, 0, 0);
1336 if (!child) 1338 if (!child)
@@ -2152,8 +2154,8 @@ void **idr_get_free(struct radix_tree_root *root,
2152 shift -= RADIX_TREE_MAP_SHIFT; 2154 shift -= RADIX_TREE_MAP_SHIFT;
2153 if (child == NULL) { 2155 if (child == NULL) {
2154 /* Have to add a child node. */ 2156 /* Have to add a child node. */
2155 child = radix_tree_node_alloc(gfp, node, shift, offset, 2157 child = radix_tree_node_alloc(gfp, node, root, shift,
2156 0, 0); 2158 offset, 0, 0);
2157 if (!child) 2159 if (!child)
2158 return ERR_PTR(-ENOMEM); 2160 return ERR_PTR(-ENOMEM);
2159 all_tag_set(child, IDR_FREE); 2161 all_tag_set(child, IDR_FREE);