提交 a8e4da25 编写于 作者: M Matthew Wilcox 提交者: Linus Torvalds

radix-tree: tidy up range_tag_if_tagged

Convert radix_tree_range_tag_if_tagged to name the nodes parent, node
and child instead of node & slot.

Use parent->offset instead of playing games with 'upindex'.
Signed-off-by: NMatthew 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: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 8c1244de
...@@ -1009,9 +1009,9 @@ unsigned long radix_tree_range_tag_if_tagged(struct radix_tree_root *root, ...@@ -1009,9 +1009,9 @@ unsigned long radix_tree_range_tag_if_tagged(struct radix_tree_root *root,
unsigned long nr_to_tag, unsigned long nr_to_tag,
unsigned int iftag, unsigned int settag) unsigned int iftag, unsigned int settag)
{ {
struct radix_tree_node *slot, *node = NULL; struct radix_tree_node *parent, *node, *child;
unsigned long maxindex; unsigned long maxindex;
unsigned int shift = radix_tree_load_root(root, &slot, &maxindex); unsigned int shift = radix_tree_load_root(root, &child, &maxindex);
unsigned long tagged = 0; unsigned long tagged = 0;
unsigned long index = *first_indexp; unsigned long index = *first_indexp;
...@@ -1024,28 +1024,25 @@ unsigned long radix_tree_range_tag_if_tagged(struct radix_tree_root *root, ...@@ -1024,28 +1024,25 @@ unsigned long radix_tree_range_tag_if_tagged(struct radix_tree_root *root,
*first_indexp = last_index + 1; *first_indexp = last_index + 1;
return 0; return 0;
} }
if (!radix_tree_is_internal_node(slot)) { if (!radix_tree_is_internal_node(child)) {
*first_indexp = last_index + 1; *first_indexp = last_index + 1;
root_tag_set(root, settag); root_tag_set(root, settag);
return 1; return 1;
} }
node = entry_to_node(slot); node = entry_to_node(child);
shift -= RADIX_TREE_MAP_SHIFT; shift -= RADIX_TREE_MAP_SHIFT;
for (;;) { for (;;) {
unsigned long upindex; unsigned offset = (index >> shift) & RADIX_TREE_MAP_MASK;
unsigned offset; offset = radix_tree_descend(node, &child, offset);
if (!child)
offset = (index >> shift) & RADIX_TREE_MAP_MASK;
offset = radix_tree_descend(node, &slot, offset);
if (!slot)
goto next; goto next;
if (!tag_get(node, iftag, offset)) if (!tag_get(node, iftag, offset))
goto next; goto next;
/* Sibling slots never have tags set on them */ /* Sibling slots never have tags set on them */
if (radix_tree_is_internal_node(slot)) { if (radix_tree_is_internal_node(child)) {
node = entry_to_node(slot); node = entry_to_node(child);
shift -= RADIX_TREE_MAP_SHIFT; shift -= RADIX_TREE_MAP_SHIFT;
continue; continue;
} }
...@@ -1054,20 +1051,18 @@ unsigned long radix_tree_range_tag_if_tagged(struct radix_tree_root *root, ...@@ -1054,20 +1051,18 @@ unsigned long radix_tree_range_tag_if_tagged(struct radix_tree_root *root,
tagged++; tagged++;
tag_set(node, settag, offset); tag_set(node, settag, offset);
slot = node->parent;
/* walk back up the path tagging interior nodes */ /* walk back up the path tagging interior nodes */
upindex = index >> shift; parent = node;
while (slot) { for (;;) {
upindex >>= RADIX_TREE_MAP_SHIFT; offset = parent->offset;
offset = upindex & RADIX_TREE_MAP_MASK; parent = parent->parent;
if (!parent)
break;
/* stop if we find a node with the tag already set */ /* stop if we find a node with the tag already set */
if (tag_get(slot, settag, offset)) if (tag_get(parent, settag, offset))
break; break;
tag_set(slot, settag, offset); tag_set(parent, settag, offset);
slot = slot->parent;
} }
next: next:
/* Go to next item at level determined by 'shift' */ /* Go to next item at level determined by 'shift' */
index = ((index >> shift) + 1) << shift; index = ((index >> shift) + 1) << shift;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册