Commit 30b888ba authored by Matthew Wilcox's avatar Matthew Wilcox

radix-tree: Add radix_tree_iter_tag_clear()

The counterpart to radix_tree_iter_tag_set(), used by the IDR code
Signed-off-by: default avatarMatthew Wilcox <mawilcox@microsoft.com>
Reviewed-by: default avatarRehas Sachdeva <aquannie@gmail.com>
parent bfa11193
...@@ -332,7 +332,9 @@ void *radix_tree_tag_clear(struct radix_tree_root *root, ...@@ -332,7 +332,9 @@ void *radix_tree_tag_clear(struct radix_tree_root *root,
unsigned long index, unsigned int tag); unsigned long index, unsigned int tag);
int radix_tree_tag_get(const struct radix_tree_root *, int radix_tree_tag_get(const struct radix_tree_root *,
unsigned long index, unsigned int tag); unsigned long index, unsigned int tag);
void radix_tree_iter_tag_set(struct radix_tree_root *root, void radix_tree_iter_tag_set(struct radix_tree_root *,
const struct radix_tree_iter *iter, unsigned int tag);
void radix_tree_iter_tag_clear(struct radix_tree_root *,
const struct radix_tree_iter *iter, unsigned int tag); const struct radix_tree_iter *iter, unsigned int tag);
unsigned int unsigned int
radix_tree_gang_lookup_tag(const struct radix_tree_root *, void **results, radix_tree_gang_lookup_tag(const struct radix_tree_root *, void **results,
......
...@@ -1266,6 +1266,22 @@ int radix_tree_split(struct radix_tree_root *root, unsigned long index, ...@@ -1266,6 +1266,22 @@ int radix_tree_split(struct radix_tree_root *root, unsigned long index,
} }
#endif #endif
static void node_tag_set(struct radix_tree_root *root,
struct radix_tree_node *node,
unsigned int tag, unsigned int offset)
{
while (node) {
if (tag_get(node, tag, offset))
return;
tag_set(node, tag, offset);
offset = node->offset;
node = node->parent;
}
if (!root_tag_get(root, tag))
root_tag_set(root, tag);
}
/** /**
* radix_tree_tag_set - set a tag on a radix tree node * radix_tree_tag_set - set a tag on a radix tree node
* @root: radix tree root * @root: radix tree root
...@@ -1307,6 +1323,18 @@ void *radix_tree_tag_set(struct radix_tree_root *root, ...@@ -1307,6 +1323,18 @@ void *radix_tree_tag_set(struct radix_tree_root *root,
} }
EXPORT_SYMBOL(radix_tree_tag_set); EXPORT_SYMBOL(radix_tree_tag_set);
/**
* radix_tree_iter_tag_set - set a tag on the current iterator entry
* @root: radix tree root
* @iter: iterator state
* @tag: tag to set
*/
void radix_tree_iter_tag_set(struct radix_tree_root *root,
const struct radix_tree_iter *iter, unsigned int tag)
{
node_tag_set(root, iter->node, tag, iter_offset(iter));
}
static void node_tag_clear(struct radix_tree_root *root, static void node_tag_clear(struct radix_tree_root *root,
struct radix_tree_node *node, struct radix_tree_node *node,
unsigned int tag, unsigned int offset) unsigned int tag, unsigned int offset)
...@@ -1327,34 +1355,6 @@ static void node_tag_clear(struct radix_tree_root *root, ...@@ -1327,34 +1355,6 @@ static void node_tag_clear(struct radix_tree_root *root,
root_tag_clear(root, tag); root_tag_clear(root, tag);
} }
static void node_tag_set(struct radix_tree_root *root,
struct radix_tree_node *node,
unsigned int tag, unsigned int offset)
{
while (node) {
if (tag_get(node, tag, offset))
return;
tag_set(node, tag, offset);
offset = node->offset;
node = node->parent;
}
if (!root_tag_get(root, tag))
root_tag_set(root, tag);
}
/**
* radix_tree_iter_tag_set - set a tag on the current iterator entry
* @root: radix tree root
* @iter: iterator state
* @tag: tag to set
*/
void radix_tree_iter_tag_set(struct radix_tree_root *root,
const struct radix_tree_iter *iter, unsigned int tag)
{
node_tag_set(root, iter->node, tag, iter_offset(iter));
}
/** /**
* radix_tree_tag_clear - clear a tag on a radix tree node * radix_tree_tag_clear - clear a tag on a radix tree node
* @root: radix tree root * @root: radix tree root
...@@ -1394,6 +1394,18 @@ void *radix_tree_tag_clear(struct radix_tree_root *root, ...@@ -1394,6 +1394,18 @@ void *radix_tree_tag_clear(struct radix_tree_root *root,
} }
EXPORT_SYMBOL(radix_tree_tag_clear); EXPORT_SYMBOL(radix_tree_tag_clear);
/**
* radix_tree_iter_tag_clear - clear a tag on the current iterator entry
* @root: radix tree root
* @iter: iterator state
* @tag: tag to clear
*/
void radix_tree_iter_tag_clear(struct radix_tree_root *root,
const struct radix_tree_iter *iter, unsigned int tag)
{
node_tag_clear(root, iter->node, tag, iter_offset(iter));
}
/** /**
* radix_tree_tag_get - get a tag on a radix tree node * radix_tree_tag_get - get a tag on a radix tree node
* @root: radix tree root * @root: radix tree root
......
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