History

raid6_kunit: cleanup dataptr handling

Move the global dataptr array into test_recover() as all sites that fill data or parity can use test_buffers directly, and this localized the override for the failed slots to the recovery testing routine.

Christoph Hellwig committed 6 months ago

Commit 562bcbf1 parent d67c2571 file · +7 −12Browse files

Showing the changes to lib/raid (1 of 1 file). Show all

Unified · Split

lib/raid/raid6/tests/raid6_kunit.c+7−12
@@ -18,7 +18,6 @@ MODULE_IMPORT_NS("EXPORTED_FOR_KUNIT_TESTING"); · 17 unmodified lines
1818 #define NDISKS 16 /* Including P and Q */
1919
2020 static struct rnd_state rng;
21−static void *dataptrs[NDISKS];
2221 static void *test_buffers[NDISKS];
2322 static void *test_recov_buffers[RAID6_KUNIT_MAX_FAILURES];
2423
@@ -35,10 +34,8 @@ static void makedata(int start, int stop) · 10 unmodified lines
3534 {
3635 int i;
3736
38− for (i = start; i <= stop; i++) {
37+ for (i = start; i <= stop; i++)
3938 prandom_bytes_state(&rng, test_buffers[i], PAGE_SIZE);
40− dataptrs[i] = test_buffers[i];
41− }
4239 }
4340
4441 static char member_type(int d)
@@ -56,11 +53,13 @@ static char member_type(int d) · 11 unmodified lines
5653 static void test_recover(struct kunit *test, int faila, int failb)
5754 {
5855 const struct test_args *ta = test->param_value;
56+ void *dataptrs[NDISKS];
5957 int i;
6058
6159 for (i = 0; i < RAID6_KUNIT_MAX_FAILURES; i++)
6260 memset(test_recov_buffers[i], 0xf0, PAGE_SIZE);
6361
62+ memcpy(dataptrs, test_buffers, sizeof(dataptrs));
6463 dataptrs[faila] = test_recov_buffers[0];
6564 dataptrs[failb] = test_recov_buffers[1];
6665
@@ -70,7 +69,7 @@ static void test_recover(struct kunit *test, int faila, int failb) · 3 unmodified lines
7069 * is equivalent to a RAID-5 failure (XOR, then recompute Q).
7170 */
7271 if (faila != NDISKS - 2)
73− goto skip;
72+ return;
7473
7574 /* P+Q failure. Just rebuild the syndrome. */
7675 ta->gen->gen_syndrome(NDISKS, PAGE_SIZE, dataptrs);
@@ -92,10 +91,6 @@ static void test_recover(struct kunit *test, int faila, int failb) · 15 unmodified lines
9291 "failb miscompared: %3d[%c] (faila=%3d[%c])\n",
9392 failb, member_type(failb),
9493 faila, member_type(faila));
95−
96−skip:
97− dataptrs[faila] = test_buffers[faila];
98− dataptrs[failb] = test_buffers[failb];
9994 }
10095
10196 static void raid6_test(struct kunit *test)
@@ -108,7 +103,7 @@ static void raid6_test(struct kunit *test) · 6 unmodified lines
108103 memset(test_buffers[NDISKS - 1], 0xee, PAGE_SIZE);
109104
110105 /* Generate assumed good syndrome */
111− ta->gen->gen_syndrome(NDISKS, PAGE_SIZE, (void **)&dataptrs);
106+ ta->gen->gen_syndrome(NDISKS, PAGE_SIZE, test_buffers);
112107
113108 for (i = 0; i < NDISKS - 1; i++)
114109 for (j = i + 1; j < NDISKS; j++)
@@ -121,10 +116,10 @@ static void raid6_test(struct kunit *test) · 6 unmodified lines
121116 for (p2 = p1; p2 < NDISKS - 2; p2++) {
122117 /* Simulate rmw run */
123118 ta->gen->xor_syndrome(NDISKS, p1, p2, PAGE_SIZE,
124− (void **)&dataptrs);
119+ test_buffers);
125120 makedata(p1, p2);
126121 ta->gen->xor_syndrome(NDISKS, p1, p2, PAGE_SIZE,
127− (void **)&dataptrs);
122+ test_buffers);
128123
129124 for (i = 0; i < NDISKS - 1; i++)
130125 for (j = i + 1; j < NDISKS; j++)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t