MCPcopy Create free account
hub / github.com/F-Stack/f-stack / vdev_raidz_cksum_finish

Function vdev_raidz_cksum_finish

freebsd/contrib/openzfs/module/zfs/vdev_raidz.c:210–295  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

208}
209
210static void
211vdev_raidz_cksum_finish(zio_cksum_report_t *zcr, const abd_t *good_data)
212{
213 raidz_map_t *rm = zcr->zcr_cbdata;
214 const size_t c = zcr->zcr_cbinfo;
215 size_t x, offset;
216
217 if (good_data == NULL) {
218 zfs_ereport_finish_checksum(zcr, NULL, NULL, B_FALSE);
219 return;
220 }
221
222 ASSERT3U(rm->rm_nrows, ==, 1);
223 raidz_row_t *rr = rm->rm_row[0];
224
225 const abd_t *good = NULL;
226 const abd_t *bad = rr->rr_col[c].rc_abd;
227
228 if (c < rr->rr_firstdatacol) {
229 /*
230 * The first time through, calculate the parity blocks for
231 * the good data (this relies on the fact that the good
232 * data never changes for a given logical ZIO)
233 */
234 if (rr->rr_col[0].rc_gdata == NULL) {
235 abd_t *bad_parity[VDEV_RAIDZ_MAXPARITY];
236
237 /*
238 * Set up the rr_col[]s to generate the parity for
239 * good_data, first saving the parity bufs and
240 * replacing them with buffers to hold the result.
241 */
242 for (x = 0; x < rr->rr_firstdatacol; x++) {
243 bad_parity[x] = rr->rr_col[x].rc_abd;
244 rr->rr_col[x].rc_abd = rr->rr_col[x].rc_gdata =
245 abd_alloc_sametype(rr->rr_col[x].rc_abd,
246 rr->rr_col[x].rc_size);
247 }
248
249 /* fill in the data columns from good_data */
250 offset = 0;
251 for (; x < rr->rr_cols; x++) {
252 abd_put(rr->rr_col[x].rc_abd);
253
254 rr->rr_col[x].rc_abd =
255 abd_get_offset_size((abd_t *)good_data,
256 offset, rr->rr_col[x].rc_size);
257 offset += rr->rr_col[x].rc_size;
258 }
259
260 /*
261 * Construct the parity from the good data.
262 */
263 vdev_raidz_generate_parity_row(rm, rr);
264
265 /* restore everything back to its original state */
266 for (x = 0; x < rr->rr_firstdatacol; x++)
267 rr->rr_col[x].rc_abd = bad_parity[x];

Callers

nothing calls this directly

Calls 5

abd_alloc_sametypeFunction · 0.85
abd_putFunction · 0.85
abd_get_offset_sizeFunction · 0.85

Tested by

no test coverage detected