aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorMatthew Wilcox <willy@linux.intel.com>2016-05-20 20:03:13 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2016-05-20 20:58:30 -0400
commitfb209019c92a9141fd73f3c4928edc1b299b3490 (patch)
tree77fe9c542dc018fd135fb89c8ac4165f4b6ed077 /lib
parentc12e51b07b3ac4c188fd91a82f96840fdb9cca6f (diff)
radix-tree: remove a use of root->height from delete_node
If radix_tree_shrink returns whether it managed to shrink, then __radix_tree_delete_node doesn't ned to query the tree to find out whether it did any work or not. Signed-off-by: Matthew Wilcox <willy@linux.intel.com> Cc: Konstantin Khlebnikov <koct9i@gmail.com> Cc: Kirill Shutemov <kirill.shutemov@linux.intel.com> Cc: Jan Kara <jack@suse.com> Cc: Neil Brown <neilb@suse.de> Cc: Ross Zwisler <ross.zwisler@linux.intel.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
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 648da9080418..75c9e6197b5b 100644
--- a/lib/radix-tree.c
+++ b/lib/radix-tree.c
@@ -1415,8 +1415,10 @@ unsigned long radix_tree_locate_item(struct radix_tree_root *root, void *item)
1415 * radix_tree_shrink - shrink height of a radix tree to minimal 1415 * radix_tree_shrink - shrink height of a radix tree to minimal
1416 * @root radix tree root 1416 * @root radix tree root
1417 */ 1417 */
1418static inline void radix_tree_shrink(struct radix_tree_root *root) 1418static inline bool radix_tree_shrink(struct radix_tree_root *root)
1419{ 1419{
1420 bool shrunk = false;
1421
1420 /* try to shrink tree height */ 1422 /* try to shrink tree height */
1421 while (root->height > 0) { 1423 while (root->height > 0) {
1422 struct radix_tree_node *to_free = root->rnode; 1424 struct radix_tree_node *to_free = root->rnode;
@@ -1476,7 +1478,10 @@ static inline void radix_tree_shrink(struct radix_tree_root *root)
1476 to_free->slots[0] = RADIX_TREE_RETRY; 1478 to_free->slots[0] = RADIX_TREE_RETRY;
1477 1479
1478 radix_tree_node_free(to_free); 1480 radix_tree_node_free(to_free);
1481 shrunk = true;
1479 } 1482 }
1483
1484 return shrunk;
1480} 1485}
1481 1486
1482/** 1487/**
@@ -1499,11 +1504,8 @@ bool __radix_tree_delete_node(struct radix_tree_root *root,
1499 struct radix_tree_node *parent; 1504 struct radix_tree_node *parent;
1500 1505
1501 if (node->count) { 1506 if (node->count) {
1502 if (node == indirect_to_ptr(root->rnode)) { 1507 if (node == indirect_to_ptr(root->rnode))
1503 radix_tree_shrink(root); 1508 deleted |= radix_tree_shrink(root);
1504 if (root->height == 0)
1505 deleted = true;
1506 }
1507 return deleted; 1509 return deleted;
1508 } 1510 }
1509 1511