Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 16891
b: refs/heads/master
c: 6e954b9
h: refs/heads/master
i:
  16889: aa4be30
  16887: b6e7b66
v: v3
  • Loading branch information
Nick Piggin authored and Linus Torvalds committed Jan 9, 2006
1 parent 8856521 commit f7244aa
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 32 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: d4829cd5b4bd1ea58ba1bebad44d562f4027c290
refs/heads/master: 6e954b9e90c3a7157c0c1457dd3919e2a1345d23
57 changes: 26 additions & 31 deletions trunk/lib/radix-tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,20 @@ static inline int tag_get(struct radix_tree_node *node, int tag, int offset)
return test_bit(offset, &node->tags[tag][0]);
}

/*
* Returns 1 if any slot in the node has this tag set.
* Otherwise returns 0.
*/
static inline int any_tag_set(struct radix_tree_node *node, int tag)
{
int idx;
for (idx = 0; idx < RADIX_TREE_TAG_LONGS; idx++) {
if (node->tags[tag][idx])
return 1;
}
return 0;
}

/*
* Return the maximum key which can be store into a
* radix tree with height HEIGHT.
Expand Down Expand Up @@ -185,15 +199,9 @@ static int radix_tree_extend(struct radix_tree_root *root, unsigned long index)
* into the newly-pushed top-level node(s)
*/
for (tag = 0; tag < RADIX_TREE_TAGS; tag++) {
int idx;

tags[tag] = 0;
for (idx = 0; idx < RADIX_TREE_TAG_LONGS; idx++) {
if (root->rnode->tags[tag][idx]) {
tags[tag] = 1;
break;
}
}
if (any_tag_set(root->rnode, tag))
tags[tag] = 1;
}

do {
Expand Down Expand Up @@ -427,13 +435,9 @@ void *radix_tree_tag_clear(struct radix_tree_root *root,
goto out;

do {
int idx;

tag_clear(pathp->node, tag, pathp->offset);
for (idx = 0; idx < RADIX_TREE_TAG_LONGS; idx++) {
if (pathp->node->tags[tag][idx])
goto out;
}
if (any_tag_set(pathp->node, tag))
goto out;
pathp--;
} while (pathp->node);
out:
Expand Down Expand Up @@ -729,19 +733,14 @@ void *radix_tree_delete(struct radix_tree_root *root, unsigned long index)

nr_cleared_tags = RADIX_TREE_TAGS;
for (tag = 0; tag < RADIX_TREE_TAGS; tag++) {
int idx;

if (tags[tag])
continue;

tag_clear(pathp->node, tag, pathp->offset);

for (idx = 0; idx < RADIX_TREE_TAG_LONGS; idx++) {
if (pathp->node->tags[tag][idx]) {
tags[tag] = 1;
nr_cleared_tags--;
break;
}
if (any_tag_set(pathp->node, tag)) {
tags[tag] = 1;
nr_cleared_tags--;
}
}
pathp--;
Expand Down Expand Up @@ -770,15 +769,11 @@ EXPORT_SYMBOL(radix_tree_delete);
*/
int radix_tree_tagged(struct radix_tree_root *root, int tag)
{
int idx;

if (!root->rnode)
return 0;
for (idx = 0; idx < RADIX_TREE_TAG_LONGS; idx++) {
if (root->rnode->tags[tag][idx])
return 1;
}
return 0;
struct radix_tree_node *rnode;
rnode = root->rnode;
if (!rnode)
return 0;
return any_tag_set(rnode, tag);
}
EXPORT_SYMBOL(radix_tree_tagged);

Expand Down

0 comments on commit f7244aa

Please sign in to comment.