2 * RAID-6 data recovery in dual failure mode based on the XC instruction.
4 * Copyright IBM Corp. 2016
5 * Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com>
8 #include <linux/export.h>
9 #include <linux/raid/pq.h>
11 static inline void xor_block(u8
*p1
, u8
*p2
)
13 typedef struct { u8 _
[256]; } addrtype
;
16 " xc 0(256,%[p1]),0(%[p2])\n"
17 : "+m" (*(addrtype
*) p1
) : "m" (*(addrtype
*) p2
),
18 [p1
] "a" (p1
), [p2
] "a" (p2
) : "cc");
21 /* Recover two failed data blocks. */
22 static void raid6_2data_recov_s390xc(int disks
, size_t bytes
, int faila
,
23 int failb
, void **ptrs
)
26 const u8
*pbmul
; /* P multiplier table for B data */
27 const u8
*qmul
; /* Q multiplier table (for both) */
30 p
= (u8
*)ptrs
[disks
-2];
31 q
= (u8
*)ptrs
[disks
-1];
33 /* Compute syndrome with zero for the missing data pages
34 Use the dead data pages as temporary storage for
35 delta p and delta q */
36 dp
= (u8
*)ptrs
[faila
];
37 ptrs
[faila
] = (void *)raid6_empty_zero_page
;
39 dq
= (u8
*)ptrs
[failb
];
40 ptrs
[failb
] = (void *)raid6_empty_zero_page
;
43 raid6_call
.gen_syndrome(disks
, bytes
, ptrs
);
45 /* Restore pointer table */
51 /* Now, pick the proper data tables */
52 pbmul
= raid6_gfmul
[raid6_gfexi
[failb
-faila
]];
53 qmul
= raid6_gfmul
[raid6_gfinv
[raid6_gfexp
[faila
]^raid6_gfexp
[failb
]]];
59 for (i
= 0; i
< 256; i
++)
60 dq
[i
] = pbmul
[dp
[i
]] ^ qmul
[dq
[i
]];
70 /* Recover failure of one data block plus the P block */
71 static void raid6_datap_recov_s390xc(int disks
, size_t bytes
, int faila
,
75 const u8
*qmul
; /* Q multiplier table */
78 p
= (u8
*)ptrs
[disks
-2];
79 q
= (u8
*)ptrs
[disks
-1];
81 /* Compute syndrome with zero for the missing data page
82 Use the dead data page as temporary storage for delta q */
83 dq
= (u8
*)ptrs
[faila
];
84 ptrs
[faila
] = (void *)raid6_empty_zero_page
;
87 raid6_call
.gen_syndrome(disks
, bytes
, ptrs
);
89 /* Restore pointer table */
93 /* Now, pick the proper data tables */
94 qmul
= raid6_gfmul
[raid6_gfinv
[raid6_gfexp
[faila
]]];
99 for (i
= 0; i
< 256; i
++)
110 const struct raid6_recov_calls raid6_recov_s390xc
= {
111 .data2
= raid6_2data_recov_s390xc
,
112 .datap
= raid6_datap_recov_s390xc
,