264 if (rm->rm_col[c].rc_gdata != NULL)
265 zio_buf_free(rm->rm_col[c].rc_gdata,
266 rm->rm_col[c].rc_size);
267 }
268
269 size = 0;
270 for (c = rm->rm_firstdatacol; c < rm->rm_cols; c++)
271 size += rm->rm_col[c].rc_size;
272
273 if (rm->rm_datacopy != NULL)
274 zio_buf_free(rm->rm_datacopy, size);
275
276 kmem_free(rm, offsetof(raidz_map_t, rm_col[rm->rm_scols]));
277 }
278
279 static void
280 vdev_raidz_map_free_vsd(zio_t *zio)
281 {
282 raidz_map_t *rm = zio->io_vsd;
283
284 ASSERT3U(rm->rm_freed, ==, 0);
285 rm->rm_freed = 1;
286
287 if (rm->rm_reports == 0)
288 vdev_raidz_map_free(rm);
289 }
290
291 /*ARGSUSED*/
292 static void
293 vdev_raidz_cksum_free(void *arg, size_t ignored)
294 {
295 raidz_map_t *rm = arg;
296
297 ASSERT3U(rm->rm_reports, >, 0);
298
299 if (--rm->rm_reports == 0 && rm->rm_freed != 0)
300 vdev_raidz_map_free(rm);
301 }
302
303 static void
304 vdev_raidz_cksum_finish(zio_cksum_report_t *zcr, const void *good_data)
1117
1118 /*
1119 * Subtract all trivial rows from the rows of consequence.
1120 */
1121 for (i = 0; i < nmissing; i++) {
1122 for (j = nmissing; j < n; j++) {
1123 ASSERT3U(used[j], >=, rm->rm_firstdatacol);
1124 jj = used[j] - rm->rm_firstdatacol;
1125 ASSERT3S(jj, <, n);
1126 invrows[i][j] = rows[i][jj];
1127 rows[i][jj] = 0;
1128 }
1129 }
1130
1131 /*
1132 * For each of the rows of interest, we must normalize it and subtract
1133 * a multiple of it from the other rows.
1134 */
1135 for (i = 0; i < nmissing; i++) {
1136 for (j = 0; j < missing[i]; j++) {
1137 ASSERT3U(rows[i][j], ==, 0);
1138 }
1139 ASSERT3U(rows[i][missing[i]], !=, 0);
1140
1141 /*
1142 * Compute the inverse of the first element and multiply each
1143 * element in the row by that value.
1144 */
1145 log = 255 - vdev_raidz_log2[rows[i][missing[i]]];
1146
1147 for (j = 0; j < n; j++) {
1148 rows[i][j] = vdev_raidz_exp2(rows[i][j], log);
1149 invrows[i][j] = vdev_raidz_exp2(invrows[i][j], log);
1150 }
1151
1152 for (ii = 0; ii < nmissing; ii++) {
1153 if (i == ii)
1154 continue;
1155
1156 ASSERT3U(rows[ii][missing[i]], !=, 0);
1157
1158 log = vdev_raidz_log2[rows[ii][missing[i]]];
1159
1160 for (j = 0; j < n; j++) {
1161 rows[ii][j] ^=
1162 vdev_raidz_exp2(rows[i][j], log);
1163 invrows[ii][j] ^=
1164 vdev_raidz_exp2(invrows[i][j], log);
1165 }
1166 }
1167 }
1168
1169 /*
1170 * Verify that the data that is left in the rows are properly part of
1171 * an identity matrix.
1172 */
1173 for (i = 0; i < nmissing; i++) {
1174 for (j = 0; j < n; j++) {
1175 if (j == missing[i]) {
1176 ASSERT3U(rows[i][j], ==, 1);
1177 } else {
1178 ASSERT3U(rows[i][j], ==, 0);
1179 }
1180 }
1181 }
1182 }
1183
1184 static void
1185 vdev_raidz_matrix_reconstruct(raidz_map_t *rm, int n, int nmissing,
1186 int *missing, uint8_t **invrows, const uint8_t *used)
1187 {
1188 int i, j, x, cc, c;
1189 uint8_t *src;
1190 uint64_t ccount;
1191 uint8_t *dst[VDEV_RAIDZ_MAXPARITY];
1192 uint64_t dcount[VDEV_RAIDZ_MAXPARITY];
1193 uint8_t log, val;
1194 int ll;
1195 uint8_t *invlog[VDEV_RAIDZ_MAXPARITY];
1196 uint8_t *p, *pp;
1197 size_t psize;
1198
|
264 if (rm->rm_col[c].rc_gdata != NULL)
265 zio_buf_free(rm->rm_col[c].rc_gdata,
266 rm->rm_col[c].rc_size);
267 }
268
269 size = 0;
270 for (c = rm->rm_firstdatacol; c < rm->rm_cols; c++)
271 size += rm->rm_col[c].rc_size;
272
273 if (rm->rm_datacopy != NULL)
274 zio_buf_free(rm->rm_datacopy, size);
275
276 kmem_free(rm, offsetof(raidz_map_t, rm_col[rm->rm_scols]));
277 }
278
279 static void
280 vdev_raidz_map_free_vsd(zio_t *zio)
281 {
282 raidz_map_t *rm = zio->io_vsd;
283
284 ASSERT0(rm->rm_freed);
285 rm->rm_freed = 1;
286
287 if (rm->rm_reports == 0)
288 vdev_raidz_map_free(rm);
289 }
290
291 /*ARGSUSED*/
292 static void
293 vdev_raidz_cksum_free(void *arg, size_t ignored)
294 {
295 raidz_map_t *rm = arg;
296
297 ASSERT3U(rm->rm_reports, >, 0);
298
299 if (--rm->rm_reports == 0 && rm->rm_freed != 0)
300 vdev_raidz_map_free(rm);
301 }
302
303 static void
304 vdev_raidz_cksum_finish(zio_cksum_report_t *zcr, const void *good_data)
1117
1118 /*
1119 * Subtract all trivial rows from the rows of consequence.
1120 */
1121 for (i = 0; i < nmissing; i++) {
1122 for (j = nmissing; j < n; j++) {
1123 ASSERT3U(used[j], >=, rm->rm_firstdatacol);
1124 jj = used[j] - rm->rm_firstdatacol;
1125 ASSERT3S(jj, <, n);
1126 invrows[i][j] = rows[i][jj];
1127 rows[i][jj] = 0;
1128 }
1129 }
1130
1131 /*
1132 * For each of the rows of interest, we must normalize it and subtract
1133 * a multiple of it from the other rows.
1134 */
1135 for (i = 0; i < nmissing; i++) {
1136 for (j = 0; j < missing[i]; j++) {
1137 ASSERT0(rows[i][j]);
1138 }
1139 ASSERT3U(rows[i][missing[i]], !=, 0);
1140
1141 /*
1142 * Compute the inverse of the first element and multiply each
1143 * element in the row by that value.
1144 */
1145 log = 255 - vdev_raidz_log2[rows[i][missing[i]]];
1146
1147 for (j = 0; j < n; j++) {
1148 rows[i][j] = vdev_raidz_exp2(rows[i][j], log);
1149 invrows[i][j] = vdev_raidz_exp2(invrows[i][j], log);
1150 }
1151
1152 for (ii = 0; ii < nmissing; ii++) {
1153 if (i == ii)
1154 continue;
1155
1156 ASSERT3U(rows[ii][missing[i]], !=, 0);
1157
1158 log = vdev_raidz_log2[rows[ii][missing[i]]];
1159
1160 for (j = 0; j < n; j++) {
1161 rows[ii][j] ^=
1162 vdev_raidz_exp2(rows[i][j], log);
1163 invrows[ii][j] ^=
1164 vdev_raidz_exp2(invrows[i][j], log);
1165 }
1166 }
1167 }
1168
1169 /*
1170 * Verify that the data that is left in the rows are properly part of
1171 * an identity matrix.
1172 */
1173 for (i = 0; i < nmissing; i++) {
1174 for (j = 0; j < n; j++) {
1175 if (j == missing[i]) {
1176 ASSERT3U(rows[i][j], ==, 1);
1177 } else {
1178 ASSERT0(rows[i][j]);
1179 }
1180 }
1181 }
1182 }
1183
1184 static void
1185 vdev_raidz_matrix_reconstruct(raidz_map_t *rm, int n, int nmissing,
1186 int *missing, uint8_t **invrows, const uint8_t *used)
1187 {
1188 int i, j, x, cc, c;
1189 uint8_t *src;
1190 uint64_t ccount;
1191 uint8_t *dst[VDEV_RAIDZ_MAXPARITY];
1192 uint64_t dcount[VDEV_RAIDZ_MAXPARITY];
1193 uint8_t log, val;
1194 int ll;
1195 uint8_t *invlog[VDEV_RAIDZ_MAXPARITY];
1196 uint8_t *p, *pp;
1197 size_t psize;
1198
|