diff options
| -rw-r--r-- | lib/test_xarray.c | 33 | ||||
| -rw-r--r-- | lib/xarray.c | 8 |
2 files changed, 36 insertions, 5 deletions
diff --git a/lib/test_xarray.c b/lib/test_xarray.c index 6f09c845187e..4676c0a1eeca 100644 --- a/lib/test_xarray.c +++ b/lib/test_xarray.c | |||
| @@ -633,6 +633,15 @@ static noinline void check_xa_alloc(void) | |||
| 633 | GFP_KERNEL) != -ENOSPC); | 633 | GFP_KERNEL) != -ENOSPC); |
| 634 | XA_BUG_ON(&xa0, id != 0xffffffffU); | 634 | XA_BUG_ON(&xa0, id != 0xffffffffU); |
| 635 | xa_destroy(&xa0); | 635 | xa_destroy(&xa0); |
| 636 | |||
| 637 | id = 10; | ||
| 638 | XA_BUG_ON(&xa0, xa_alloc(&xa0, &id, 5, xa_mk_index(id), | ||
| 639 | GFP_KERNEL) != -ENOSPC); | ||
| 640 | XA_BUG_ON(&xa0, xa_store_index(&xa0, 3, GFP_KERNEL) != 0); | ||
| 641 | XA_BUG_ON(&xa0, xa_alloc(&xa0, &id, 5, xa_mk_index(id), | ||
| 642 | GFP_KERNEL) != -ENOSPC); | ||
| 643 | xa_erase_index(&xa0, 3); | ||
| 644 | XA_BUG_ON(&xa0, !xa_empty(&xa0)); | ||
| 636 | } | 645 | } |
| 637 | 646 | ||
| 638 | static noinline void __check_store_iter(struct xarray *xa, unsigned long start, | 647 | static noinline void __check_store_iter(struct xarray *xa, unsigned long start, |
| @@ -822,10 +831,34 @@ static noinline void check_find_2(struct xarray *xa) | |||
| 822 | xa_destroy(xa); | 831 | xa_destroy(xa); |
| 823 | } | 832 | } |
| 824 | 833 | ||
| 834 | static noinline void check_find_3(struct xarray *xa) | ||
| 835 | { | ||
| 836 | XA_STATE(xas, xa, 0); | ||
| 837 | unsigned long i, j, k; | ||
| 838 | void *entry; | ||
| 839 | |||
| 840 | for (i = 0; i < 100; i++) { | ||
| 841 | for (j = 0; j < 100; j++) { | ||
| 842 | for (k = 0; k < 100; k++) { | ||
| 843 | xas_set(&xas, j); | ||
| 844 | xas_for_each_marked(&xas, entry, k, XA_MARK_0) | ||
| 845 | ; | ||
| 846 | if (j > k) | ||
| 847 | XA_BUG_ON(xa, | ||
| 848 | xas.xa_node != XAS_RESTART); | ||
| 849 | } | ||
| 850 | } | ||
| 851 | xa_store_index(xa, i, GFP_KERNEL); | ||
| 852 | xa_set_mark(xa, i, XA_MARK_0); | ||
| 853 | } | ||
| 854 | xa_destroy(xa); | ||
| 855 | } | ||
| 856 | |||
| 825 | static noinline void check_find(struct xarray *xa) | 857 | static noinline void check_find(struct xarray *xa) |
| 826 | { | 858 | { |
| 827 | check_find_1(xa); | 859 | check_find_1(xa); |
| 828 | check_find_2(xa); | 860 | check_find_2(xa); |
| 861 | check_find_3(xa); | ||
| 829 | check_multi_find(xa); | 862 | check_multi_find(xa); |
| 830 | check_multi_find_2(xa); | 863 | check_multi_find_2(xa); |
| 831 | } | 864 | } |
diff --git a/lib/xarray.c b/lib/xarray.c index bbacca576593..5f3f9311de89 100644 --- a/lib/xarray.c +++ b/lib/xarray.c | |||
| @@ -1131,7 +1131,7 @@ void *xas_find_marked(struct xa_state *xas, unsigned long max, xa_mark_t mark) | |||
| 1131 | entry = xa_head(xas->xa); | 1131 | entry = xa_head(xas->xa); |
| 1132 | xas->xa_node = NULL; | 1132 | xas->xa_node = NULL; |
| 1133 | if (xas->xa_index > max_index(entry)) | 1133 | if (xas->xa_index > max_index(entry)) |
| 1134 | goto bounds; | 1134 | goto out; |
| 1135 | if (!xa_is_node(entry)) { | 1135 | if (!xa_is_node(entry)) { |
| 1136 | if (xa_marked(xas->xa, mark)) | 1136 | if (xa_marked(xas->xa, mark)) |
| 1137 | return entry; | 1137 | return entry; |
| @@ -1180,11 +1180,9 @@ void *xas_find_marked(struct xa_state *xas, unsigned long max, xa_mark_t mark) | |||
| 1180 | } | 1180 | } |
| 1181 | 1181 | ||
| 1182 | out: | 1182 | out: |
| 1183 | if (!max) | 1183 | if (xas->xa_index > max) |
| 1184 | goto max; | 1184 | goto max; |
| 1185 | bounds: | 1185 | return set_bounds(xas); |
| 1186 | xas->xa_node = XAS_BOUNDS; | ||
| 1187 | return NULL; | ||
| 1188 | max: | 1186 | max: |
| 1189 | xas->xa_node = XAS_RESTART; | 1187 | xas->xa_node = XAS_RESTART; |
| 1190 | return NULL; | 1188 | return NULL; |
