Commit ec57d6e6 authored by James Simmons's avatar James Simmons Committed by Greg Kroah-Hartman

staging: lustre: ldlm: restore interval_iterate_reverse function

Earlier the function interval_iterate_reverse function was
removed since it wasn't used by anyone. Now it is being
restored since it will be used by a future patch.
Signed-off-by: default avatarJames Simmons <jsimmons@infradead.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent e16ffa83
......@@ -111,4 +111,8 @@ enum interval_iter interval_search(struct interval_node *root,
struct interval_node_extent *ex,
interval_callback_t func, void *data);
enum interval_iter interval_iterate_reverse(struct interval_node *root,
interval_callback_t func,
void *data);
#endif
......@@ -110,6 +110,15 @@ static struct interval_node *interval_first(struct interval_node *node)
return node;
}
static struct interval_node *interval_last(struct interval_node *node)
{
if (!node)
return NULL;
while (node->in_right)
node = node->in_right;
return node;
}
static struct interval_node *interval_next(struct interval_node *node)
{
if (!node)
......@@ -121,6 +130,37 @@ static struct interval_node *interval_next(struct interval_node *node)
return node->in_parent;
}
static struct interval_node *interval_prev(struct interval_node *node)
{
if (!node)
return NULL;
if (node->in_left)
return interval_last(node->in_left);
while (node->in_parent && node_is_left_child(node))
node = node->in_parent;
return node->in_parent;
}
enum interval_iter interval_iterate_reverse(struct interval_node *root,
interval_callback_t func,
void *data)
{
enum interval_iter rc = INTERVAL_ITER_CONT;
struct interval_node *node;
for (node = interval_last(root); node; node = interval_prev(node)) {
rc = func(node, data);
if (rc == INTERVAL_ITER_STOP)
break;
}
return rc;
}
EXPORT_SYMBOL(interval_iterate_reverse);
static void __rotate_change_maxhigh(struct interval_node *node,
struct interval_node *rotate)
{
......
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