Commit 4589ba6d authored by Ross Zwisler's avatar Ross Zwisler Committed by Linus Torvalds

radix-tree: rewrite radix_tree_tag_get

Use the new multi-order support functions to rewrite
radix_tree_tag_get()
Signed-off-by: default avatarRoss Zwisler <ross.zwisler@linux.intel.com>
Signed-off-by: default avatarMatthew 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>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 00f47b58
...@@ -831,45 +831,37 @@ EXPORT_SYMBOL(radix_tree_tag_clear); ...@@ -831,45 +831,37 @@ EXPORT_SYMBOL(radix_tree_tag_clear);
int radix_tree_tag_get(struct radix_tree_root *root, int radix_tree_tag_get(struct radix_tree_root *root,
unsigned long index, unsigned int tag) unsigned long index, unsigned int tag)
{ {
unsigned int height, shift; struct radix_tree_node *node, *parent;
struct radix_tree_node *node; unsigned long maxindex;
unsigned int shift;
/* check the root's tag bit */
if (!root_tag_get(root, tag)) if (!root_tag_get(root, tag))
return 0; return 0;
node = rcu_dereference_raw(root->rnode); shift = radix_tree_load_root(root, &node, &maxindex);
if (index > maxindex)
return 0;
if (node == NULL) if (node == NULL)
return 0; return 0;
if (!radix_tree_is_indirect_ptr(node)) while (radix_tree_is_indirect_ptr(node)) {
return (index == 0); int offset;
node = indirect_to_ptr(node);
height = node->path & RADIX_TREE_HEIGHT_MASK;
if (index > radix_tree_maxindex(height))
return 0;
shift = (height - 1) * RADIX_TREE_MAP_SHIFT; shift -= RADIX_TREE_MAP_SHIFT;
offset = (index >> shift) & RADIX_TREE_MAP_MASK;
for ( ; ; ) { parent = indirect_to_ptr(node);
int offset; offset = radix_tree_descend(parent, &node, offset);
if (node == NULL) if (!node)
return 0; return 0;
node = indirect_to_ptr(node); if (!tag_get(parent, tag, offset))
offset = (index >> shift) & RADIX_TREE_MAP_MASK;
if (!tag_get(node, tag, offset))
return 0; return 0;
if (height == 1) if (node == RADIX_TREE_RETRY)
return 1; break;
node = rcu_dereference_raw(node->slots[offset]);
if (!radix_tree_is_indirect_ptr(node))
return 1;
shift -= RADIX_TREE_MAP_SHIFT;
height--;
} }
return 1;
} }
EXPORT_SYMBOL(radix_tree_tag_get); EXPORT_SYMBOL(radix_tree_tag_get);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment