radix tree test suite: handle exceptional entries
authorMatthew Wilcox <[email protected]>
Wed, 14 Dec 2016 23:08:20 +0000 (15:08 -0800)
committerLinus Torvalds <[email protected]>
Thu, 15 Dec 2016 00:04:10 +0000 (16:04 -0800)
item_kill_tree() assumes that everything in the tree is a pointer to a
struct item, which is annoying when testing the behaviour of exceptional
entries.  Fix it to delete exceptional entries on the assumption they
don't need to be freed.

Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Matthew Wilcox <[email protected]>
Tested-by: Kirill A. Shutemov <[email protected]>
Cc: Konstantin Khlebnikov <[email protected]>
Cc: Ross Zwisler <[email protected]>
Cc: Matthew Wilcox <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
tools/testing/radix-tree/test.c

index a6e8099eaf4f27e6f58c67565fa2344578831043..6f8dafc797ce84e8988abed16aba785d938be95c 100644 (file)
@@ -200,9 +200,16 @@ void verify_tag_consistency(struct radix_tree_root *root, unsigned int tag)
 
 void item_kill_tree(struct radix_tree_root *root)
 {
+       struct radix_tree_iter iter;
+       void **slot;
        struct item *items[32];
        int nfound;
 
+       radix_tree_for_each_slot(slot, root, &iter, 0) {
+               if (radix_tree_exceptional_entry(*slot))
+                       radix_tree_delete(root, iter.index);
+       }
+
        while ((nfound = radix_tree_gang_lookup(root, (void **)items, 0, 32))) {
                int i;