diff options
| author | Christoph Hellwig <hch@lst.de> | 2026-05-18 07:17:59 +0200 |
|---|---|---|
| committer | Andrew Morton <akpm@linux-foundation.org> | 2026-05-28 21:24:56 -0700 |
| commit | 562bcbfcb99b2eb4fd17d6551d760450e128afe1 (patch) | |
| tree | 8a79359fa927c6108912b43a37403e755c578cd4 /lib/raid | |
| parent | d67c25712fe3c5d78fea03827771c49debb89c80 (diff) | |
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.
Link: https://lore.kernel.org/20260518051804.462141-17-hch@lst.de
Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Tested-by: Ard Biesheuvel <ardb@kernel.org> # kunit only on arm64
Cc: Albert Ou <aou@eecs.berkeley.edu>
Cc: Alexander Gordeev <agordeev@linux.ibm.com>
Cc: Alexandre Ghiti <alex@ghiti.fr>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: "Borislav Petkov (AMD)" <bp@alien8.de>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Chris Mason <clm@fb.com>
Cc: Christian Borntraeger <borntraeger@linux.ibm.com>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: David Sterba <dsterba@suse.com>
Cc: Heiko Carstens <hca@linux.ibm.com>
Cc: Herbert Xu <herbert@gondor.apana.org.au>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Huacai Chen <chenhuacai@kernel.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Li Nan <linan122@huawei.com>
Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Nicholas Piggin <npiggin@gmail.com>
Cc: Palmer Dabbelt <palmer@dabbelt.com>
Cc: Song Liu <song@kernel.org>
Cc: Sven Schnelle <svens@linux.ibm.com>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Cc: WANG Xuerui <kernel@xen0n.name>
Cc: Will Deacon <will@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Diffstat (limited to 'lib/raid')
| -rw-r--r-- | lib/raid/raid6/tests/raid6_kunit.c | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/lib/raid/raid6/tests/raid6_kunit.c b/lib/raid/raid6/tests/raid6_kunit.c index 72c78834df7f..152d5d1c3a88 100644 --- a/lib/raid/raid6/tests/raid6_kunit.c +++ b/lib/raid/raid6/tests/raid6_kunit.c @@ -18,7 +18,6 @@ MODULE_IMPORT_NS("EXPORTED_FOR_KUNIT_TESTING"); #define NDISKS 16 /* Including P and Q */ static struct rnd_state rng; -static void *dataptrs[NDISKS]; static void *test_buffers[NDISKS]; static void *test_recov_buffers[RAID6_KUNIT_MAX_FAILURES]; @@ -35,10 +34,8 @@ static void makedata(int start, int stop) { int i; - for (i = start; i <= stop; i++) { + for (i = start; i <= stop; i++) prandom_bytes_state(&rng, test_buffers[i], PAGE_SIZE); - dataptrs[i] = test_buffers[i]; - } } static char member_type(int d) @@ -56,11 +53,13 @@ static char member_type(int d) static void test_recover(struct kunit *test, int faila, int failb) { const struct test_args *ta = test->param_value; + void *dataptrs[NDISKS]; int i; for (i = 0; i < RAID6_KUNIT_MAX_FAILURES; i++) memset(test_recov_buffers[i], 0xf0, PAGE_SIZE); + memcpy(dataptrs, test_buffers, sizeof(dataptrs)); dataptrs[faila] = test_recov_buffers[0]; dataptrs[failb] = test_recov_buffers[1]; @@ -70,7 +69,7 @@ static void test_recover(struct kunit *test, int faila, int failb) * is equivalent to a RAID-5 failure (XOR, then recompute Q). */ if (faila != NDISKS - 2) - goto skip; + return; /* P+Q failure. Just rebuild the syndrome. */ ta->gen->gen_syndrome(NDISKS, PAGE_SIZE, dataptrs); @@ -92,10 +91,6 @@ static void test_recover(struct kunit *test, int faila, int failb) "failb miscompared: %3d[%c] (faila=%3d[%c])\n", failb, member_type(failb), faila, member_type(faila)); - -skip: - dataptrs[faila] = test_buffers[faila]; - dataptrs[failb] = test_buffers[failb]; } static void raid6_test(struct kunit *test) @@ -108,7 +103,7 @@ static void raid6_test(struct kunit *test) memset(test_buffers[NDISKS - 1], 0xee, PAGE_SIZE); /* Generate assumed good syndrome */ - ta->gen->gen_syndrome(NDISKS, PAGE_SIZE, (void **)&dataptrs); + ta->gen->gen_syndrome(NDISKS, PAGE_SIZE, test_buffers); for (i = 0; i < NDISKS - 1; i++) for (j = i + 1; j < NDISKS; j++) @@ -121,10 +116,10 @@ static void raid6_test(struct kunit *test) for (p2 = p1; p2 < NDISKS - 2; p2++) { /* Simulate rmw run */ ta->gen->xor_syndrome(NDISKS, p1, p2, PAGE_SIZE, - (void **)&dataptrs); + test_buffers); makedata(p1, p2); ta->gen->xor_syndrome(NDISKS, p1, p2, PAGE_SIZE, - (void **)&dataptrs); + test_buffers); for (i = 0; i < NDISKS - 1; i++) for (j = i + 1; j < NDISKS; j++) |
