Commit 00f47b58 authored by Ross Zwisler's avatar Ross Zwisler Committed by Linus Torvalds

radix-tree: rewrite radix_tree_tag_clear

Use the new multi-order support functions to rewrite
radix_tree_tag_clear()
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 fb969909
...@@ -768,44 +768,40 @@ EXPORT_SYMBOL(radix_tree_tag_set); ...@@ -768,44 +768,40 @@ EXPORT_SYMBOL(radix_tree_tag_set);
void *radix_tree_tag_clear(struct radix_tree_root *root, void *radix_tree_tag_clear(struct radix_tree_root *root,
unsigned long index, unsigned int tag) unsigned long index, unsigned int tag)
{ {
struct radix_tree_node *node = NULL; struct radix_tree_node *node, *parent;
struct radix_tree_node *slot = NULL; unsigned long maxindex;
unsigned int height, shift; unsigned int shift;
int uninitialized_var(offset); int uninitialized_var(offset);
height = root->height; shift = radix_tree_load_root(root, &node, &maxindex);
if (index > radix_tree_maxindex(height)) if (index > maxindex)
goto out; return NULL;
shift = height * RADIX_TREE_MAP_SHIFT;
slot = root->rnode;
while (shift) { parent = NULL;
if (slot == NULL)
goto out;
if (!radix_tree_is_indirect_ptr(slot))
break;
slot = indirect_to_ptr(slot);
while (radix_tree_is_indirect_ptr(node)) {
shift -= RADIX_TREE_MAP_SHIFT; shift -= RADIX_TREE_MAP_SHIFT;
offset = (index >> shift) & RADIX_TREE_MAP_MASK; offset = (index >> shift) & RADIX_TREE_MAP_MASK;
node = slot;
slot = slot->slots[offset]; parent = indirect_to_ptr(node);
offset = radix_tree_descend(parent, &node, offset);
} }
if (slot == NULL) if (node == NULL)
goto out; goto out;
while (node) { index >>= shift;
if (!tag_get(node, tag, offset))
while (parent) {
if (!tag_get(parent, tag, offset))
goto out; goto out;
tag_clear(node, tag, offset); tag_clear(parent, tag, offset);
if (any_tag_set(node, tag)) if (any_tag_set(parent, tag))
goto out; goto out;
index >>= RADIX_TREE_MAP_SHIFT; index >>= RADIX_TREE_MAP_SHIFT;
offset = index & RADIX_TREE_MAP_MASK; offset = index & RADIX_TREE_MAP_MASK;
node = node->parent; parent = parent->parent;
} }
/* clear the root's tag bit */ /* clear the root's tag bit */
...@@ -813,7 +809,7 @@ void *radix_tree_tag_clear(struct radix_tree_root *root, ...@@ -813,7 +809,7 @@ void *radix_tree_tag_clear(struct radix_tree_root *root,
root_tag_clear(root, tag); root_tag_clear(root, tag);
out: out:
return slot; return node;
} }
EXPORT_SYMBOL(radix_tree_tag_clear); EXPORT_SYMBOL(radix_tree_tag_clear);
......
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