Commit 4bb53bdd authored by Matthew Wilcox's avatar Matthew Wilcox

radix tree tests: Move item_insert_order

The remaining tests are not suitable for moving in-kernel, so move
item_insert_order() into multiorder.c, make it static and make it use
the XArray.
Signed-off-by: default avatarMatthew Wilcox <willy@infradead.org>
parent 879a9ae7
...@@ -20,6 +20,25 @@ ...@@ -20,6 +20,25 @@
#include "test.h" #include "test.h"
static int item_insert_order(struct xarray *xa, unsigned long index,
unsigned order)
{
XA_STATE_ORDER(xas, xa, index, order);
struct item *item = item_create(index, order);
do {
xas_lock(&xas);
xas_store(&xas, item);
xas_unlock(&xas);
} while (xas_nomem(&xas, GFP_KERNEL));
if (!xas_error(&xas))
return 0;
free(item);
return xas_error(&xas);
}
void multiorder_iteration(void) void multiorder_iteration(void)
{ {
RADIX_TREE(tree, GFP_KERNEL); RADIX_TREE(tree, GFP_KERNEL);
......
...@@ -34,21 +34,15 @@ struct item *item_create(unsigned long index, unsigned int order) ...@@ -34,21 +34,15 @@ struct item *item_create(unsigned long index, unsigned int order)
return ret; return ret;
} }
int item_insert_order(struct radix_tree_root *root, unsigned long index, int item_insert(struct radix_tree_root *root, unsigned long index)
unsigned order)
{ {
struct item *item = item_create(index, order); struct item *item = item_create(index, 0);
int err = __radix_tree_insert(root, item->index, item->order, item); int err = radix_tree_insert(root, item->index, item);
if (err) if (err)
free(item); free(item);
return err; return err;
} }
int item_insert(struct radix_tree_root *root, unsigned long index)
{
return item_insert_order(root, index, 0);
}
void item_sanity(struct item *item, unsigned long index) void item_sanity(struct item *item, unsigned long index)
{ {
unsigned long mask; unsigned long mask;
......
...@@ -14,8 +14,6 @@ struct item *item_create(unsigned long index, unsigned int order); ...@@ -14,8 +14,6 @@ struct item *item_create(unsigned long index, unsigned int order);
int item_insert(struct radix_tree_root *root, unsigned long index); int item_insert(struct radix_tree_root *root, unsigned long index);
void item_sanity(struct item *item, unsigned long index); void item_sanity(struct item *item, unsigned long index);
void item_free(struct item *item, unsigned long index); void item_free(struct item *item, unsigned long index);
int item_insert_order(struct radix_tree_root *root, unsigned long index,
unsigned order);
int item_delete(struct radix_tree_root *root, unsigned long index); int item_delete(struct radix_tree_root *root, unsigned long index);
int item_delete_rcu(struct radix_tree_root *root, unsigned long index); int item_delete_rcu(struct radix_tree_root *root, unsigned long index);
struct item *item_lookup(struct radix_tree_root *root, unsigned long index); struct item *item_lookup(struct radix_tree_root *root, unsigned long index);
......
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