diff options
author | Matthew Wilcox <willy@infradead.org> | 2019-02-21 17:54:44 -0500 |
---|---|---|
committer | Matthew Wilcox <willy@infradead.org> | 2019-02-21 17:54:44 -0500 |
commit | 4a5c8d898948d1ac876522cdd62f07a78104bfe9 (patch) | |
tree | f7b60e242dc970b9f4c6524f6882a4eb9261c388 /lib/test_xarray.c | |
parent | 2fbe967b3eb7466f679307b38564b8271c093241 (diff) |
XArray: Fix xa_reserve for 2-byte aligned entries
If we reserve index 0, the next entry to be stored there might be 2-byte
aligned. That means we have to create the root xa_node at the time of
reserving the initial entry.
Signed-off-by: Matthew Wilcox <willy@infradead.org>
Diffstat (limited to 'lib/test_xarray.c')
-rw-r--r-- | lib/test_xarray.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/test_xarray.c b/lib/test_xarray.c index bc202d468a6b..5d4bad8bd96a 100644 --- a/lib/test_xarray.c +++ b/lib/test_xarray.c | |||
@@ -1355,6 +1355,10 @@ static void check_align_1(struct xarray *xa, char *name) | |||
1355 | xa_destroy(xa); | 1355 | xa_destroy(xa); |
1356 | } | 1356 | } |
1357 | 1357 | ||
1358 | /* | ||
1359 | * We should always be able to store without allocating memory after | ||
1360 | * reserving a slot. | ||
1361 | */ | ||
1358 | static void check_align_2(struct xarray *xa, char *name) | 1362 | static void check_align_2(struct xarray *xa, char *name) |
1359 | { | 1363 | { |
1360 | int i; | 1364 | int i; |
@@ -1366,6 +1370,12 @@ static void check_align_2(struct xarray *xa, char *name) | |||
1366 | xa_erase(xa, 0); | 1370 | xa_erase(xa, 0); |
1367 | } | 1371 | } |
1368 | 1372 | ||
1373 | for (i = 0; i < 8; i++) { | ||
1374 | XA_BUG_ON(xa, xa_reserve(xa, 0, GFP_KERNEL) != 0); | ||
1375 | XA_BUG_ON(xa, xa_store(xa, 0, name + i, 0) != NULL); | ||
1376 | xa_erase(xa, 0); | ||
1377 | } | ||
1378 | |||
1369 | XA_BUG_ON(xa, !xa_empty(xa)); | 1379 | XA_BUG_ON(xa, !xa_empty(xa)); |
1370 | } | 1380 | } |
1371 | 1381 | ||