xarray: Add definition of struct xarray
This is a direct replacement for struct radix_tree_root. Some of the struct members have changed name; convert those, and use a #define so that radix_tree users continue to work without change. Signed-off-by: Matthew Wilcox <willy@infradead.org> Reviewed-by: Josef Bacik <jbacik@fb.com>
This commit is contained in:
@@ -5,7 +5,7 @@ CFLAGS += -I. -I../../include -g -Og -Wall -D_LGPL_SOURCE -fsanitize=address \
|
||||
LDFLAGS += -fsanitize=address -fsanitize=undefined
|
||||
LDLIBS+= -lpthread -lurcu
|
||||
TARGETS = main idr-test multiorder
|
||||
CORE_OFILES := radix-tree.o idr.o linux.o test.o find_bit.o
|
||||
CORE_OFILES := xarray.o radix-tree.o idr.o linux.o test.o find_bit.o
|
||||
OFILES = main.o $(CORE_OFILES) regression1.o regression2.o regression3.o \
|
||||
tag_check.o multiorder.o idr-test.o iteration_check.o benchmark.o
|
||||
|
||||
@@ -35,6 +35,7 @@ vpath %.c ../../lib
|
||||
$(OFILES): Makefile *.h */*.h generated/map-shift.h \
|
||||
../../include/linux/*.h \
|
||||
../../include/asm/*.h \
|
||||
../../../include/linux/xarray.h \
|
||||
../../../include/linux/radix-tree.h \
|
||||
../../../include/linux/idr.h
|
||||
|
||||
@@ -44,6 +45,8 @@ radix-tree.c: ../../../lib/radix-tree.c
|
||||
idr.c: ../../../lib/idr.c
|
||||
sed -e 's/^static //' -e 's/__always_inline //' -e 's/inline //' < $< > $@
|
||||
|
||||
xarray.o: ../../../lib/xarray.c
|
||||
|
||||
generated/map-shift.h:
|
||||
@if ! grep -qws $(SHIFT) generated/map-shift.h; then \
|
||||
echo "#define XA_CHUNK_SHIFT $(SHIFT)" > \
|
||||
|
@@ -1 +1,2 @@
|
||||
#include <stdio.h>
|
||||
#include "asm/bug.h"
|
||||
|
1
tools/testing/radix-tree/linux/kconfig.h
Normal file
1
tools/testing/radix-tree/linux/kconfig.h
Normal file
@@ -0,0 +1 @@
|
||||
#include "../../../../include/linux/kconfig.h"
|
@@ -192,13 +192,13 @@ static void multiorder_shrink(unsigned long index, int order)
|
||||
|
||||
assert(item_insert_order(&tree, 0, order) == 0);
|
||||
|
||||
node = tree.rnode;
|
||||
node = tree.xa_head;
|
||||
|
||||
assert(item_insert(&tree, index) == 0);
|
||||
assert(node != tree.rnode);
|
||||
assert(node != tree.xa_head);
|
||||
|
||||
assert(item_delete(&tree, index) != 0);
|
||||
assert(node == tree.rnode);
|
||||
assert(node == tree.xa_head);
|
||||
|
||||
for (i = 0; i < max; i++) {
|
||||
struct item *item = item_lookup(&tree, i);
|
||||
|
@@ -281,7 +281,7 @@ static int verify_node(struct radix_tree_node *slot, unsigned int tag,
|
||||
|
||||
void verify_tag_consistency(struct radix_tree_root *root, unsigned int tag)
|
||||
{
|
||||
struct radix_tree_node *node = root->rnode;
|
||||
struct radix_tree_node *node = root->xa_head;
|
||||
if (!radix_tree_is_internal_node(node))
|
||||
return;
|
||||
verify_node(node, tag, !!root_tag_get(root, tag));
|
||||
@@ -311,13 +311,13 @@ void item_kill_tree(struct radix_tree_root *root)
|
||||
}
|
||||
}
|
||||
assert(radix_tree_gang_lookup(root, (void **)items, 0, 32) == 0);
|
||||
assert(root->rnode == NULL);
|
||||
assert(root->xa_head == NULL);
|
||||
}
|
||||
|
||||
void tree_verify_min_height(struct radix_tree_root *root, int maxindex)
|
||||
{
|
||||
unsigned shift;
|
||||
struct radix_tree_node *node = root->rnode;
|
||||
struct radix_tree_node *node = root->xa_head;
|
||||
if (!radix_tree_is_internal_node(node)) {
|
||||
assert(maxindex == 0);
|
||||
return;
|
||||
|
7
tools/testing/radix-tree/xarray.c
Normal file
7
tools/testing/radix-tree/xarray.c
Normal file
@@ -0,0 +1,7 @@
|
||||
// SPDX-License-Identifier: GPL-2.0+
|
||||
/*
|
||||
* xarray.c: Userspace shim for XArray test-suite
|
||||
* Copyright (c) 2018 Matthew Wilcox <willy@infradead.org>
|
||||
*/
|
||||
|
||||
#include "../../../lib/xarray.c"
|
Reference in New Issue
Block a user