diff options
| author | Christoph Hellwig <hch@lst.de> | 2026-05-18 07:17:46 +0200 |
|---|---|---|
| committer | Andrew Morton <akpm@linux-foundation.org> | 2026-05-28 21:24:53 -0700 |
| commit | 3626738bc7147d52cb49f3994a9846aa2d34810a (patch) | |
| tree | 683cf2b4f8028ae1d915dcd5a549047d0971e311 /lib/raid6/test | |
| parent | 3d6beb659ddf0664612bafacb0bd9030ba6ec7e6 (diff) | |
raid6: move to lib/raid/
Move the raid6 code to live in lib/raid/ with the XOR code, and change the
internal organization so that each architecture has a subdirectory similar
to the CRC, crypto and XOR libraries, and fix up the Makefile to only
build files actually needed.
Also move the kunit test case from the history test/ subdirectory to
tests/ and use the normal naming scheme for it.
Link: https://lore.kernel.org/20260518051804.462141-4-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/raid6/test')
| -rw-r--r-- | lib/raid6/test/.gitignore | 3 | ||||
| -rw-r--r-- | lib/raid6/test/Makefile | 5 | ||||
| -rw-r--r-- | lib/raid6/test/test.c | 160 |
3 files changed, 0 insertions, 168 deletions
diff --git a/lib/raid6/test/.gitignore b/lib/raid6/test/.gitignore deleted file mode 100644 index 1b68a77f348f..000000000000 --- a/lib/raid6/test/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -/int.uc -/neon.uc -/raid6test diff --git a/lib/raid6/test/Makefile b/lib/raid6/test/Makefile deleted file mode 100644 index 520381ea71d7..000000000000 --- a/lib/raid6/test/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0 - -obj-$(CONFIG_RAID6_PQ_KUNIT_TEST) += raid6_kunit.o - -raid6_kunit-y += test.o diff --git a/lib/raid6/test/test.c b/lib/raid6/test/test.c deleted file mode 100644 index 9db287b4a48f..000000000000 --- a/lib/raid6/test/test.c +++ /dev/null @@ -1,160 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later -/* - * Copyright 2002-2007 H. Peter Anvin - All Rights Reserved - * - * Test RAID-6 recovery algorithms. - */ - -#include <kunit/test.h> -#include <linux/prandom.h> -#include <linux/raid/pq.h> - -MODULE_IMPORT_NS("EXPORTED_FOR_KUNIT_TESTING"); - -#define RAID6_KUNIT_SEED 42 - -#define NDISKS 16 /* Including P and Q */ - -static struct rnd_state rng; -static void *dataptrs[NDISKS]; -static char data[NDISKS][PAGE_SIZE] __attribute__((aligned(PAGE_SIZE))); -static char recovi[PAGE_SIZE] __attribute__((aligned(PAGE_SIZE))); -static char recovj[PAGE_SIZE] __attribute__((aligned(PAGE_SIZE))); - -static void makedata(int start, int stop) -{ - int i; - - for (i = start; i <= stop; i++) { - prandom_bytes_state(&rng, data[i], PAGE_SIZE); - dataptrs[i] = data[i]; - } -} - -static char member_type(int d) -{ - switch (d) { - case NDISKS-2: - return 'P'; - case NDISKS-1: - return 'Q'; - default: - return 'D'; - } -} - -static void test_disks(struct kunit *test, const struct raid6_calls *calls, - const struct raid6_recov_calls *ra, int faila, int failb) -{ - memset(recovi, 0xf0, PAGE_SIZE); - memset(recovj, 0xba, PAGE_SIZE); - - dataptrs[faila] = recovi; - dataptrs[failb] = recovj; - - if (failb == NDISKS - 1) { - /* - * We don't implement the data+Q failure scenario, since it - * is equivalent to a RAID-5 failure (XOR, then recompute Q). - */ - if (faila != NDISKS - 2) - goto skip; - - /* P+Q failure. Just rebuild the syndrome. */ - calls->gen_syndrome(NDISKS, PAGE_SIZE, dataptrs); - } else if (failb == NDISKS - 2) { - /* data+P failure. */ - ra->datap(NDISKS, PAGE_SIZE, faila, dataptrs); - } else { - /* data+data failure. */ - ra->data2(NDISKS, PAGE_SIZE, faila, failb, dataptrs); - } - - KUNIT_EXPECT_MEMEQ_MSG(test, data[faila], recovi, PAGE_SIZE, - "algo=%-8s/%-8s faila miscompared: %3d[%c] (failb=%3d[%c])\n", - calls->name, ra->name, - faila, member_type(faila), - failb, member_type(failb)); - KUNIT_EXPECT_MEMEQ_MSG(test, data[failb], recovj, PAGE_SIZE, - "algo=%-8s/%-8s failb miscompared: %3d[%c] (faila=%3d[%c])\n", - calls->name, ra->name, - failb, member_type(failb), - faila, member_type(faila)); - -skip: - dataptrs[faila] = data[faila]; - dataptrs[failb] = data[failb]; -} - -static void raid6_test(struct kunit *test) -{ - const struct raid6_calls *const *algo; - const struct raid6_recov_calls *const *ra; - int i, j, p1, p2; - - for (ra = raid6_recov_algos; *ra; ra++) { - if ((*ra)->valid && !(*ra)->valid()) - continue; - - for (algo = raid6_algos; *algo; algo++) { - const struct raid6_calls *calls = *algo; - - if (calls->valid && !calls->valid()) - continue; - - /* Nuke syndromes */ - memset(data[NDISKS - 2], 0xee, PAGE_SIZE); - memset(data[NDISKS - 1], 0xee, PAGE_SIZE); - - /* Generate assumed good syndrome */ - calls->gen_syndrome(NDISKS, PAGE_SIZE, - (void **)&dataptrs); - - for (i = 0; i < NDISKS-1; i++) - for (j = i+1; j < NDISKS; j++) - test_disks(test, calls, *ra, i, j); - - if (!calls->xor_syndrome) - continue; - - for (p1 = 0; p1 < NDISKS-2; p1++) - for (p2 = p1; p2 < NDISKS-2; p2++) { - - /* Simulate rmw run */ - calls->xor_syndrome(NDISKS, p1, p2, PAGE_SIZE, - (void **)&dataptrs); - makedata(p1, p2); - calls->xor_syndrome(NDISKS, p1, p2, PAGE_SIZE, - (void **)&dataptrs); - - for (i = 0; i < NDISKS-1; i++) - for (j = i+1; j < NDISKS; j++) - test_disks(test, calls, - *ra, i, j); - } - - } - } -} - -static struct kunit_case raid6_test_cases[] = { - KUNIT_CASE(raid6_test), - {}, -}; - -static int raid6_suite_init(struct kunit_suite *suite) -{ - prandom_seed_state(&rng, RAID6_KUNIT_SEED); - makedata(0, NDISKS - 1); - return 0; -} - -static struct kunit_suite raid6_test_suite = { - .name = "raid6", - .test_cases = raid6_test_cases, - .suite_init = raid6_suite_init, -}; -kunit_test_suite(raid6_test_suite); - -MODULE_DESCRIPTION("Unit test for the RAID P/Q library functions"); -MODULE_LICENSE("GPL"); |
