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

Function raidz_parity_verify

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

* Generate the parity from the data columns. If we tried and were able to * read the parity without error, verify that the generated parity matches the * data we read. If it doesn't, we fire off a checksum error. Return the * number of such failures. */

Source from the content-addressed store, hash-verified

1908 * number of such failures.
1909 */
1910static int
1911raidz_parity_verify(zio_t *zio, raidz_row_t *rr)
1912{
1913 abd_t *orig[VDEV_RAIDZ_MAXPARITY];
1914 int c, ret = 0;
1915 raidz_map_t *rm = zio->io_vsd;
1916 raidz_col_t *rc;
1917
1918 blkptr_t *bp = zio->io_bp;
1919 enum zio_checksum checksum = (bp == NULL ? zio->io_prop.zp_checksum :
1920 (BP_IS_GANG(bp) ? ZIO_CHECKSUM_GANG_HEADER : BP_GET_CHECKSUM(bp)));
1921
1922 if (checksum == ZIO_CHECKSUM_NOPARITY)
1923 return (ret);
1924
1925 for (c = 0; c < rr->rr_firstdatacol; c++) {
1926 rc = &rr->rr_col[c];
1927 if (!rc->rc_tried || rc->rc_error != 0)
1928 continue;
1929
1930 orig[c] = abd_alloc_sametype(rc->rc_abd, rc->rc_size);
1931 abd_copy(orig[c], rc->rc_abd, rc->rc_size);
1932 }
1933
1934 /*
1935 * Regenerates parity even for !tried||rc_error!=0 columns. This
1936 * isn't harmful but it does have the side effect of fixing stuff
1937 * we didn't realize was necessary (i.e. even if we return 0).
1938 */
1939 vdev_raidz_generate_parity_row(rm, rr);
1940
1941 for (c = 0; c < rr->rr_firstdatacol; c++) {
1942 rc = &rr->rr_col[c];
1943
1944 if (!rc->rc_tried || rc->rc_error != 0)
1945 continue;
1946
1947 if (abd_cmp(orig[c], rc->rc_abd) != 0) {
1948 raidz_checksum_error(zio, rc, orig[c]);
1949 rc->rc_error = SET_ERROR(ECKSUM);
1950 ret++;
1951 }
1952 abd_free(orig[c]);
1953 }
1954
1955 return (ret);
1956}
1957
1958static int
1959vdev_raidz_worst_error(raidz_row_t *rr)

Callers 1

Calls 6

abd_alloc_sametypeFunction · 0.85
abd_copyFunction · 0.85
abd_cmpFunction · 0.85
raidz_checksum_errorFunction · 0.85
abd_freeFunction · 0.85

Tested by

no test coverage detected