diff options
author | Matthew Wilcox <willy@linux.intel.com> | 2016-05-20 20:03:24 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2016-05-20 20:58:30 -0400 |
commit | a4db4dcea1b3990e8c5dc8a03d11f36a3c0c6d8b (patch) | |
tree | 3aa6c5252688494b1a84aed1210cf672dd838343 /lib | |
parent | 30ff46ccb303fb6f6c28b9aa9f2cdc4ba900ed3f (diff) |
radix-tree: rename ptr_to_indirect() to node_to_entry()
ptr_to_indirect() was a bad name. What it really means is "Convert this
pointer to a node into an entry suitable for storing in the radix tree".
So node_to_entry() seemed like a better name.
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.c | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/lib/radix-tree.c b/lib/radix-tree.c index 31d5929a625b..f66bb3932452 100644 --- a/lib/radix-tree.c +++ b/lib/radix-tree.c | |||
@@ -66,12 +66,12 @@ struct radix_tree_preload { | |||
66 | }; | 66 | }; |
67 | static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads) = { 0, }; | 67 | static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads) = { 0, }; |
68 | 68 | ||
69 | static inline void *ptr_to_indirect(void *ptr) | 69 | static inline void *node_to_entry(void *ptr) |
70 | { | 70 | { |
71 | return (void *)((unsigned long)ptr | RADIX_TREE_INTERNAL_NODE); | 71 | return (void *)((unsigned long)ptr | RADIX_TREE_INTERNAL_NODE); |
72 | } | 72 | } |
73 | 73 | ||
74 | #define RADIX_TREE_RETRY ptr_to_indirect(NULL) | 74 | #define RADIX_TREE_RETRY node_to_entry(NULL) |
75 | 75 | ||
76 | #ifdef CONFIG_RADIX_TREE_MULTIORDER | 76 | #ifdef CONFIG_RADIX_TREE_MULTIORDER |
77 | /* Sibling slots point directly to another slot in the same node */ | 77 | /* Sibling slots point directly to another slot in the same node */ |
@@ -470,13 +470,12 @@ static int radix_tree_extend(struct radix_tree_root *root, | |||
470 | if (radix_tree_is_indirect_ptr(slot)) { | 470 | if (radix_tree_is_indirect_ptr(slot)) { |
471 | slot = indirect_to_ptr(slot); | 471 | slot = indirect_to_ptr(slot); |
472 | slot->parent = node; | 472 | slot->parent = node; |
473 | slot = ptr_to_indirect(slot); | 473 | slot = node_to_entry(slot); |
474 | } | 474 | } |
475 | node->slots[0] = slot; | 475 | node->slots[0] = slot; |
476 | node = ptr_to_indirect(node); | 476 | slot = node_to_entry(node); |
477 | rcu_assign_pointer(root->rnode, node); | 477 | rcu_assign_pointer(root->rnode, slot); |
478 | shift += RADIX_TREE_MAP_SHIFT; | 478 | shift += RADIX_TREE_MAP_SHIFT; |
479 | slot = node; | ||
480 | } while (shift <= maxshift); | 479 | } while (shift <= maxshift); |
481 | out: | 480 | out: |
482 | return maxshift + RADIX_TREE_MAP_SHIFT; | 481 | return maxshift + RADIX_TREE_MAP_SHIFT; |
@@ -534,11 +533,11 @@ int __radix_tree_create(struct radix_tree_root *root, unsigned long index, | |||
534 | slot->parent = node; | 533 | slot->parent = node; |
535 | if (node) { | 534 | if (node) { |
536 | rcu_assign_pointer(node->slots[offset], | 535 | rcu_assign_pointer(node->slots[offset], |
537 | ptr_to_indirect(slot)); | 536 | node_to_entry(slot)); |
538 | node->count++; | 537 | node->count++; |
539 | } else | 538 | } else |
540 | rcu_assign_pointer(root->rnode, | 539 | rcu_assign_pointer(root->rnode, |
541 | ptr_to_indirect(slot)); | 540 | node_to_entry(slot)); |
542 | } else if (!radix_tree_is_indirect_ptr(slot)) | 541 | } else if (!radix_tree_is_indirect_ptr(slot)) |
543 | break; | 542 | break; |
544 | 543 | ||
@@ -553,7 +552,7 @@ int __radix_tree_create(struct radix_tree_root *root, unsigned long index, | |||
553 | if (order > shift) { | 552 | if (order > shift) { |
554 | int i, n = 1 << (order - shift); | 553 | int i, n = 1 << (order - shift); |
555 | offset = offset & ~(n - 1); | 554 | offset = offset & ~(n - 1); |
556 | slot = ptr_to_indirect(&node->slots[offset]); | 555 | slot = node_to_entry(&node->slots[offset]); |
557 | for (i = 0; i < n; i++) { | 556 | for (i = 0; i < n; i++) { |
558 | if (node->slots[offset + i]) | 557 | if (node->slots[offset + i]) |
559 | return -EEXIST; | 558 | return -EEXIST; |
@@ -1422,7 +1421,7 @@ static inline bool radix_tree_shrink(struct radix_tree_root *root) | |||
1422 | if (radix_tree_is_indirect_ptr(slot)) { | 1421 | if (radix_tree_is_indirect_ptr(slot)) { |
1423 | slot = indirect_to_ptr(slot); | 1422 | slot = indirect_to_ptr(slot); |
1424 | slot->parent = NULL; | 1423 | slot->parent = NULL; |
1425 | slot = ptr_to_indirect(slot); | 1424 | slot = node_to_entry(slot); |
1426 | } | 1425 | } |
1427 | 1426 | ||
1428 | /* | 1427 | /* |
@@ -1563,7 +1562,7 @@ void *radix_tree_delete_item(struct radix_tree_root *root, | |||
1563 | radix_tree_tag_clear(root, index, tag); | 1562 | radix_tree_tag_clear(root, index, tag); |
1564 | } | 1563 | } |
1565 | 1564 | ||
1566 | delete_sibling_entries(node, ptr_to_indirect(slot), offset); | 1565 | delete_sibling_entries(node, node_to_entry(slot), offset); |
1567 | node->slots[offset] = NULL; | 1566 | node->slots[offset] = NULL; |
1568 | node->count--; | 1567 | node->count--; |
1569 | 1568 | ||