hc
2024-05-10 ee930fffee469d076998274a2ca55e13dc1efb67
kernel/crypto/async_tx/raid6test.c
....@@ -1,23 +1,10 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * asynchronous raid6 recovery self test
34 * Copyright (c) 2009, Intel Corporation.
45 *
56 * based on drivers/md/raid6test/test.c:
67 * Copyright 2002-2007 H. Peter Anvin
7
- *
8
- * This program is free software; you can redistribute it and/or modify it
9
- * under the terms and conditions of the GNU General Public License,
10
- * version 2, as published by the Free Software Foundation.
11
- *
12
- * This program is distributed in the hope it will be useful, but WITHOUT
13
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15
- * more details.
16
- *
17
- * You should have received a copy of the GNU General Public License along with
18
- * this program; if not, write to the Free Software Foundation, Inc.,
19
- * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
20
- *
218 */
229 #include <linux/async_tx.h>
2310 #include <linux/gfp.h>
....@@ -31,6 +18,7 @@
3118 #define NDISKS 64 /* Including P and Q */
3219
3320 static struct page *dataptrs[NDISKS];
21
+unsigned int dataoffs[NDISKS];
3422 static addr_conv_t addr_conv[NDISKS];
3523 static struct page *data[NDISKS+3];
3624 static struct page *spare;
....@@ -51,6 +39,7 @@
5139 for (i = 0; i < disks; i++) {
5240 prandom_bytes(page_address(data[i]), PAGE_SIZE);
5341 dataptrs[i] = data[i];
42
+ dataoffs[i] = 0;
5443 }
5544 }
5645
....@@ -65,7 +54,8 @@
6554 }
6655
6756 /* Recover two failed blocks. */
68
-static void raid6_dual_recov(int disks, size_t bytes, int faila, int failb, struct page **ptrs)
57
+static void raid6_dual_recov(int disks, size_t bytes, int faila, int failb,
58
+ struct page **ptrs, unsigned int *offs)
6959 {
7060 struct async_submit_ctl submit;
7161 struct completion cmp;
....@@ -79,7 +69,8 @@
7969 if (faila == disks-2) {
8070 /* P+Q failure. Just rebuild the syndrome. */
8171 init_async_submit(&submit, 0, NULL, NULL, NULL, addr_conv);
82
- tx = async_gen_syndrome(ptrs, 0, disks, bytes, &submit);
72
+ tx = async_gen_syndrome(ptrs, offs,
73
+ disks, bytes, &submit);
8374 } else {
8475 struct page *blocks[NDISKS];
8576 struct page *dest;
....@@ -102,22 +93,26 @@
10293 tx = async_xor(dest, blocks, 0, count, bytes, &submit);
10394
10495 init_async_submit(&submit, 0, tx, NULL, NULL, addr_conv);
105
- tx = async_gen_syndrome(ptrs, 0, disks, bytes, &submit);
96
+ tx = async_gen_syndrome(ptrs, offs,
97
+ disks, bytes, &submit);
10698 }
10799 } else {
108100 if (failb == disks-2) {
109101 /* data+P failure. */
110102 init_async_submit(&submit, 0, NULL, NULL, NULL, addr_conv);
111
- tx = async_raid6_datap_recov(disks, bytes, faila, ptrs, &submit);
103
+ tx = async_raid6_datap_recov(disks, bytes,
104
+ faila, ptrs, offs, &submit);
112105 } else {
113106 /* data+data failure. */
114107 init_async_submit(&submit, 0, NULL, NULL, NULL, addr_conv);
115
- tx = async_raid6_2data_recov(disks, bytes, faila, failb, ptrs, &submit);
108
+ tx = async_raid6_2data_recov(disks, bytes,
109
+ faila, failb, ptrs, offs, &submit);
116110 }
117111 }
118112 init_completion(&cmp);
119113 init_async_submit(&submit, ASYNC_TX_ACK, tx, callback, &cmp, addr_conv);
120
- tx = async_syndrome_val(ptrs, 0, disks, bytes, &result, spare, &submit);
114
+ tx = async_syndrome_val(ptrs, offs,
115
+ disks, bytes, &result, spare, 0, &submit);
121116 async_tx_issue_pending(tx);
122117
123118 if (wait_for_completion_timeout(&cmp, msecs_to_jiffies(3000)) == 0)
....@@ -139,7 +134,7 @@
139134 dataptrs[i] = recovi;
140135 dataptrs[j] = recovj;
141136
142
- raid6_dual_recov(disks, PAGE_SIZE, i, j, dataptrs);
137
+ raid6_dual_recov(disks, PAGE_SIZE, i, j, dataptrs, dataoffs);
143138
144139 erra = memcmp(page_address(data[i]), page_address(recovi), PAGE_SIZE);
145140 errb = memcmp(page_address(data[j]), page_address(recovj), PAGE_SIZE);
....@@ -175,7 +170,7 @@
175170 /* Generate assumed good syndrome */
176171 init_completion(&cmp);
177172 init_async_submit(&submit, ASYNC_TX_ACK, NULL, callback, &cmp, addr_conv);
178
- tx = async_gen_syndrome(dataptrs, 0, disks, PAGE_SIZE, &submit);
173
+ tx = async_gen_syndrome(dataptrs, dataoffs, disks, PAGE_SIZE, &submit);
179174 async_tx_issue_pending(tx);
180175
181176 if (wait_for_completion_timeout(&cmp, msecs_to_jiffies(3000)) == 0) {