Skip to contentSkip to conversation

radix-tree: rename indirect_to_ptr() to entry_to_node()

PATCH New [email protected] 1 participant 1 message May 21, 2016

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

PATCH 138/162 radix-tree: rename indirect_to_ptr() to entry_to_node()

From: Matthew Wilcox <[email protected]>
Subject: radix-tree: rename indirect_to_ptr() to entry_to_node()

Mirrors the earlier commit introducing node_to_entry().

Also change the type returned to be a struct radix_tree_node pointer. That lets us simplify a couple of places in the radix tree shrink & extend paths where we could convert an entry into a pointer, modify the node, then convert the pointer back into an entry.

Cc Konstantin Khlebnikov <[email protected]>
Cc Kirill Shutemov <[email protected]>
Cc Jan Kara <[email protected]>
Cc Neil Brown <[email protected]>
Cc Ross Zwisler <[email protected]>

---

 include/linux/radix-tree.h      |   12 +++----
 lib/radix-tree.c                |   48 +++++++++++++-----------------
 tools/testing/radix-tree/test.c |    4 +-
 tools/testing/radix-tree/test.h |    1 
 4 files changed, 28 insertions(+), 37 deletions(-)
include/linux/radix-tree.h renamed from include/linux/radix-tree.h~radix-tree-rename-indirect_to_ptr-to-entry_to_node +5 -7
diff -puN include/linux/radix-tree.h~radix-tree-rename-indirect_to_ptr-to-entry_to_node include/linux/radix-tree.h
@@ -442,7 +442,7 @@ radix_tree_chunk_size(struct radix_tree_
 	return (iter->next_index - iter->index) >> iter_shift(iter);
 }
 
-static inline void *indirect_to_ptr(void *ptr)
+static inline struct radix_tree_node *entry_to_node(void *ptr)
 {
 	return (void *)((unsigned long)ptr & ~RADIX_TREE_INTERNAL_NODE);
 }
@@ -469,7 +469,7 @@ radix_tree_next_slot(void **slot, struct
 			return NULL;
 		while (IS_ENABLED(CONFIG_RADIX_TREE_MULTIORDER) &&
 					radix_tree_is_indirect_ptr(slot[1])) {
-			if (indirect_to_ptr(slot[1]) == canon) {
+			if (entry_to_node(slot[1]) == canon) {
 				iter->tags >>= 1;
 				iter->index = __radix_tree_iter_add(iter, 1);
 				slot++;
@@ -499,12 +499,10 @@ radix_tree_next_slot(void **slot, struct
 
 			if (IS_ENABLED(CONFIG_RADIX_TREE_MULTIORDER) &&
 			    radix_tree_is_indirect_ptr(*slot)) {
-				if (indirect_to_ptr(*slot) == canon)
+				if (entry_to_node(*slot) == canon)
 					continue;
-				else {
-					iter->next_index = iter->index;
-					break;
-				}
+				iter->next_index = iter->index;
+				break;
 			}
 
 			if (likely(*slot))
lib/radix-tree.c renamed from lib/radix-tree.c~radix-tree-rename-indirect_to_ptr-to-entry_to_node +21 -27

161 lines not on this page · raw message

tools/testing/radix-tree/test.c renamed from tools/testing/radix-tree/test.c~radix-tree-rename-indirect_to_ptr-to-entry_to_node +2 -2
diff -puN tools/testing/radix-tree/test.c~radix-tree-rename-indirect_to_ptr-to-entry_to_node tools/testing/radix-tree/test.c
@@ -149,7 +149,7 @@ static int verify_node(struct radix_tree
 	int i;
 	int j;
 
-	slot = indirect_to_ptr(slot);
+	slot = entry_to_node(slot);
 
 	/* Verify consistency at this level */
 	for (i = 0; i < RADIX_TREE_TAG_LONGS; i++) {
@@ -227,7 +227,7 @@ void tree_verify_min_height(struct radix
 		return;
 	}
 
-	node = indirect_to_ptr(node);
+	node = entry_to_node(node);
 	assert(maxindex <= node_maxindex(node));
 
 	shift = node->shift;
tools/testing/radix-tree/test.h renamed from tools/testing/radix-tree/test.h~radix-tree-rename-indirect_to_ptr-to-entry_to_node +0 -1
diff -puN tools/testing/radix-tree/test.h~radix-tree-rename-indirect_to_ptr-to-entry_to_node tools/testing/radix-tree/test.h
@@ -39,7 +39,6 @@ void verify_tag_consistency(struct radix
 extern int nr_allocated;
 
 /* Normally private parts of lib/radix-tree.c */
-void *indirect_to_ptr(void *ptr);
 void radix_tree_dump(struct radix_tree_root *root);
 int root_tag_get(struct radix_tree_root *root, unsigned int tag);
 unsigned long node_maxindex(struct radix_tree_node *);

_