25 #include <linux/random.h>
26 #include <linux/module.h>
29 #define pr(fmt, args...) pr_info("raid6test: " fmt, ##args)
36 static struct page *spare;
47 static void makedata(
int disks)
51 for (i = 0; i < disks; i++) {
58 dataptrs[
i] = data[
i];
62 static char disk_type(
int d,
int disks)
66 else if (d == disks - 1)
73 static void raid6_dual_recov(
int disks,
size_t bytes,
int faila,
int failb,
struct page **
ptrs)
83 if (failb == disks-1) {
84 if (faila == disks-2) {
86 init_async_submit(&submit, 0,
NULL,
NULL,
NULL, addr_conv);
89 struct page *blocks[disks];
97 for (i = disks; i-- ; ) {
98 if (i == faila || i == failb)
100 blocks[count++] = ptrs[
i];
105 tx =
async_xor(dest, blocks, 0, count, bytes, &submit);
107 init_async_submit(&submit, 0, tx,
NULL,
NULL, addr_conv);
111 if (failb == disks-2) {
113 init_async_submit(&submit, 0,
NULL,
NULL,
NULL, addr_conv);
117 init_async_submit(&submit, 0,
NULL,
NULL,
NULL, addr_conv);
121 init_completion(&cmp);
124 async_tx_issue_pending(tx);
127 pr(
"%s: timeout! (faila: %d failb: %d disks: %d)\n",
128 __func__, faila, failb, disks);
131 pr(
"%s: validation failure! faila: %d failb: %d sum_check_flags: %x\n",
132 __func__, faila, failb, result);
135 static int test_disks(
int i,
int j,
int disks)
145 raid6_dual_recov(disks,
PAGE_SIZE, i, j, dataptrs);
150 pr(
"%s(%d, %d): faila=%3d(%c) failb=%3d(%c) %s\n",
151 __func__, i, j, i, disk_type(i, disks), j, disk_type(j, disks),
152 (!erra && !errb) ?
"OK" : !erra ?
"ERRB" : !errb ?
"ERRA" :
"ERRAB");
154 dataptrs[
i] = data[
i];
155 dataptrs[
j] = data[
j];
160 static int test(
int disks,
int *tests)
168 recovi = data[disks];
169 recovj = data[disks+1];
170 spare = data[disks+2];
179 init_completion(&cmp);
182 async_tx_issue_pending(tx);
185 pr(
"error: initial gen_syndrome(%d) timed out\n", disks);
189 pr(
"testing the %d-disk case...\n", disks);
190 for (i = 0; i < disks-1; i++)
191 for (j = i+1; j < disks; j++) {
193 err += test_disks(i, j, disks);
200 static int raid6_test(
void)
206 for (i = 0; i <
NDISKS+3; i++) {
217 err +=
test(4, &tests);
219 err +=
test(5, &tests);
224 err +=
test(11, &tests);
225 err +=
test(12, &tests);
227 err +=
test(NDISKS, &tests);
230 pr(
"complete (%d tests, %d failure%s)\n",
231 tests, err, err == 1 ?
"" :
"s");
233 for (i = 0; i < NDISKS+3; i++)
239 static void raid6_test_exit(
void)