| .. | .. | 
|---|
|  | 1 | +// SPDX-License-Identifier: GPL-2.0-only | 
|---|
| 1 | 2 | /* | 
|---|
| 2 | 3 | * asynchronous raid6 recovery self test | 
|---|
| 3 | 4 | * Copyright (c) 2009, Intel Corporation. | 
|---|
| 4 | 5 | * | 
|---|
| 5 | 6 | * based on drivers/md/raid6test/test.c: | 
|---|
| 6 | 7 | * 	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 |  | - * | 
|---|
| 21 | 8 | */ | 
|---|
| 22 | 9 | #include <linux/async_tx.h> | 
|---|
| 23 | 10 | #include <linux/gfp.h> | 
|---|
| .. | .. | 
|---|
| 31 | 18 | #define NDISKS 64 /* Including P and Q */ | 
|---|
| 32 | 19 |  | 
|---|
| 33 | 20 | static struct page *dataptrs[NDISKS]; | 
|---|
|  | 21 | +unsigned int dataoffs[NDISKS]; | 
|---|
| 34 | 22 | static addr_conv_t addr_conv[NDISKS]; | 
|---|
| 35 | 23 | static struct page *data[NDISKS+3]; | 
|---|
| 36 | 24 | static struct page *spare; | 
|---|
| .. | .. | 
|---|
| 51 | 39 | for (i = 0; i < disks; i++) { | 
|---|
| 52 | 40 | prandom_bytes(page_address(data[i]), PAGE_SIZE); | 
|---|
| 53 | 41 | dataptrs[i] = data[i]; | 
|---|
|  | 42 | +		dataoffs[i] = 0; | 
|---|
| 54 | 43 | } | 
|---|
| 55 | 44 | } | 
|---|
| 56 | 45 |  | 
|---|
| .. | .. | 
|---|
| 65 | 54 | } | 
|---|
| 66 | 55 |  | 
|---|
| 67 | 56 | /* 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) | 
|---|
| 69 | 59 | { | 
|---|
| 70 | 60 | struct async_submit_ctl submit; | 
|---|
| 71 | 61 | struct completion cmp; | 
|---|
| .. | .. | 
|---|
| 79 | 69 | if (faila == disks-2) { | 
|---|
| 80 | 70 | /* P+Q failure.  Just rebuild the syndrome. */ | 
|---|
| 81 | 71 | 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); | 
|---|
| 83 | 74 | } else { | 
|---|
| 84 | 75 | struct page *blocks[NDISKS]; | 
|---|
| 85 | 76 | struct page *dest; | 
|---|
| .. | .. | 
|---|
| 102 | 93 | tx = async_xor(dest, blocks, 0, count, bytes, &submit); | 
|---|
| 103 | 94 |  | 
|---|
| 104 | 95 | 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); | 
|---|
| 106 | 98 | } | 
|---|
| 107 | 99 | } else { | 
|---|
| 108 | 100 | if (failb == disks-2) { | 
|---|
| 109 | 101 | /* data+P failure. */ | 
|---|
| 110 | 102 | 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); | 
|---|
| 112 | 105 | } else { | 
|---|
| 113 | 106 | /* data+data failure. */ | 
|---|
| 114 | 107 | 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); | 
|---|
| 116 | 110 | } | 
|---|
| 117 | 111 | } | 
|---|
| 118 | 112 | init_completion(&cmp); | 
|---|
| 119 | 113 | 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); | 
|---|
| 121 | 116 | async_tx_issue_pending(tx); | 
|---|
| 122 | 117 |  | 
|---|
| 123 | 118 | if (wait_for_completion_timeout(&cmp, msecs_to_jiffies(3000)) == 0) | 
|---|
| .. | .. | 
|---|
| 139 | 134 | dataptrs[i] = recovi; | 
|---|
| 140 | 135 | dataptrs[j] = recovj; | 
|---|
| 141 | 136 |  | 
|---|
| 142 |  | -	raid6_dual_recov(disks, PAGE_SIZE, i, j, dataptrs); | 
|---|
|  | 137 | +	raid6_dual_recov(disks, PAGE_SIZE, i, j, dataptrs, dataoffs); | 
|---|
| 143 | 138 |  | 
|---|
| 144 | 139 | erra = memcmp(page_address(data[i]), page_address(recovi), PAGE_SIZE); | 
|---|
| 145 | 140 | errb = memcmp(page_address(data[j]), page_address(recovj), PAGE_SIZE); | 
|---|
| .. | .. | 
|---|
| 175 | 170 | /* Generate assumed good syndrome */ | 
|---|
| 176 | 171 | init_completion(&cmp); | 
|---|
| 177 | 172 | 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); | 
|---|
| 179 | 174 | async_tx_issue_pending(tx); | 
|---|
| 180 | 175 |  | 
|---|
| 181 | 176 | if (wait_for_completion_timeout(&cmp, msecs_to_jiffies(3000)) == 0) { | 
|---|