]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - lib/test_xarray.c
net/core: Do not clear VF index for node/port GUIDs query
[linux.git] / lib / test_xarray.c
index 90584c63ca39a856bce6f7aba454218e9dd947e5..55c14e8c885916b2ee96ff00a600dc8ae2a19664 100644 (file)
@@ -2,6 +2,7 @@
 /*
  * test_xarray.c: Test the XArray API
  * Copyright (c) 2017-2018 Microsoft Corporation
+ * Copyright (c) 2019-2020 Oracle
  * Author: Matthew Wilcox <willy@infradead.org>
  */
 
@@ -902,28 +903,34 @@ static noinline void check_store_iter(struct xarray *xa)
        XA_BUG_ON(xa, !xa_empty(xa));
 }
 
-static noinline void check_multi_find(struct xarray *xa)
+static noinline void check_multi_find_1(struct xarray *xa, unsigned order)
 {
 #ifdef CONFIG_XARRAY_MULTI
+       unsigned long multi = 3 << order;
+       unsigned long next = 4 << order;
        unsigned long index;
 
-       xa_store_order(xa, 12, 2, xa_mk_value(12), GFP_KERNEL);
-       XA_BUG_ON(xa, xa_store_index(xa, 16, GFP_KERNEL) != NULL);
+       xa_store_order(xa, multi, order, xa_mk_value(multi), GFP_KERNEL);
+       XA_BUG_ON(xa, xa_store_index(xa, next, GFP_KERNEL) != NULL);
+       XA_BUG_ON(xa, xa_store_index(xa, next + 1, GFP_KERNEL) != NULL);
 
        index = 0;
        XA_BUG_ON(xa, xa_find(xa, &index, ULONG_MAX, XA_PRESENT) !=
-                       xa_mk_value(12));
-       XA_BUG_ON(xa, index != 12);
-       index = 13;
+                       xa_mk_value(multi));
+       XA_BUG_ON(xa, index != multi);
+       index = multi + 1;
        XA_BUG_ON(xa, xa_find(xa, &index, ULONG_MAX, XA_PRESENT) !=
-                       xa_mk_value(12));
-       XA_BUG_ON(xa, (index < 12) || (index >= 16));
+                       xa_mk_value(multi));
+       XA_BUG_ON(xa, (index < multi) || (index >= next));
        XA_BUG_ON(xa, xa_find_after(xa, &index, ULONG_MAX, XA_PRESENT) !=
-                       xa_mk_value(16));
-       XA_BUG_ON(xa, index != 16);
-
-       xa_erase_index(xa, 12);
-       xa_erase_index(xa, 16);
+                       xa_mk_value(next));
+       XA_BUG_ON(xa, index != next);
+       XA_BUG_ON(xa, xa_find_after(xa, &index, next, XA_PRESENT) != NULL);
+       XA_BUG_ON(xa, index != next);
+
+       xa_erase_index(xa, multi);
+       xa_erase_index(xa, next);
+       xa_erase_index(xa, next + 1);
        XA_BUG_ON(xa, !xa_empty(xa));
 #endif
 }
@@ -1064,11 +1071,15 @@ static noinline void check_find_4(struct xarray *xa)
 
 static noinline void check_find(struct xarray *xa)
 {
+       unsigned i;
+
        check_find_1(xa);
        check_find_2(xa);
        check_find_3(xa);
        check_find_4(xa);
-       check_multi_find(xa);
+
+       for (i = 2; i < 10; i++)
+               check_multi_find_1(xa, i);
        check_multi_find_2(xa);
 }