Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1372863
| From | Matthew Wilcox <willy@linux.intel.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 13/30] radix-tree: Introduce radix_tree_load_root() |
| Date | 2016-04-06 23:30 +0200 |
| Message-ID | <rl3bv-1Cm-63@gated-at.bofh.it> (permalink) |
| References | <rl3bs-1Cm-3@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
All the tree walking functions start with some variant of this code;
centralise it in one place so we're not chasing subtly different bugs
everywhere.
Signed-off-by: Matthew Wilcox <willy@linux.intel.com>
Reviewed-by: Ross Zwisler <ross.zwisler@linux.intel.com>
---
lib/radix-tree.c | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/lib/radix-tree.c b/lib/radix-tree.c
index f2a314cf42cc..b3a7e6cd5773 100644
--- a/lib/radix-tree.c
+++ b/lib/radix-tree.c
@@ -405,6 +405,29 @@ static inline unsigned long radix_tree_maxindex(unsigned int height)
return height_to_maxindex[height];
}
+static inline unsigned long node_maxindex(struct radix_tree_node *node)
+{
+ return radix_tree_maxindex(node->path & RADIX_TREE_HEIGHT_MASK);
+}
+
+static unsigned radix_tree_load_root(struct radix_tree_root *root,
+ struct radix_tree_node **nodep, unsigned long *maxindex)
+{
+ struct radix_tree_node *node = rcu_dereference_raw(root->rnode);
+
+ *nodep = node;
+
+ if (likely(radix_tree_is_indirect_ptr(node))) {
+ node = indirect_to_ptr(node);
+ *maxindex = node_maxindex(node);
+ return (node->path & RADIX_TREE_HEIGHT_MASK) *
+ RADIX_TREE_MAP_SHIFT;
+ }
+
+ *maxindex = 0;
+ return 0;
+}
+
/*
* Extend a radix tree so it can store key @index.
*/
--
2.8.0.rc3
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 00/30] Radix tree multiorder fixes Matthew Wilcox <willy@linux.intel.com> - 2016-04-06 23:30 +0200 [PATCH 24/30] radix-tree: Rewrite radix_tree_tag_get Matthew Wilcox <willy@linux.intel.com> - 2016-04-06 23:30 +0200 [PATCH 21/30] radix tree test suite: Add multiorder shrinking test Matthew Wilcox <willy@linux.intel.com> - 2016-04-06 23:30 +0200 [PATCH 30/30] radix-tree: Add copyright statements Matthew Wilcox <willy@linux.intel.com> - 2016-04-06 23:30 +0200 [PATCH 13/30] radix-tree: Introduce radix_tree_load_root() Matthew Wilcox <willy@linux.intel.com> - 2016-04-06 23:30 +0200 [PATCH 02/30] radix tree test suite: Fix build Matthew Wilcox <willy@linux.intel.com> - 2016-04-06 23:40 +0200 [PATCH 05/30] radix tree test suite: keep regression test runs short Matthew Wilcox <willy@linux.intel.com> - 2016-04-06 23:40 +0200 [PATCH 06/30] radix tree test suite: rebuild when headers change Matthew Wilcox <willy@linux.intel.com> - 2016-04-06 23:40 +0200 [PATCH 10/30] radix-tree: Fix sibling entry insertion Matthew Wilcox <willy@linux.intel.com> - 2016-04-06 23:40 +0200 [PATCH 11/30] radix-tree: Fix deleting a multi-order entry through an alias Matthew Wilcox <willy@linux.intel.com> - 2016-04-06 23:40 +0200 [PATCH 01/30] radix-tree: Introduce radix_tree_empty Matthew Wilcox <willy@linux.intel.com> - 2016-04-06 23:40 +0200
csiph-web