From 87e89536f105ea2a3b1e3120569129bb314d9853 Mon Sep 17 00:00:00 2001 From: Pawel Jakub Dawidek Date: Sat, 14 Apr 2007 20:50:14 +0000 Subject: [PATCH] Fix RAID-Z resilvering. Obtained from: OpenSolaris --- .../opensolaris/uts/common/fs/zfs/vdev_raidz.c | 18 ++++++++++++++++-- .../opensolaris/uts/common/fs/zfs/vdev_raidz.c | 18 ++++++++++++++++-- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_raidz.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_raidz.c index 08df7e09ba08..0c866307653b 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_raidz.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_raidz.c @@ -867,8 +867,18 @@ vdev_raidz_io_done(zio_t *zio) case 0: if (zio_checksum_error(zio) == 0) { zio->io_error = 0; + + /* + * If we read parity information (unnecessarily + * as it happens since no reconstruction was + * needed) regenerate and verify the parity. + * We also regenerate parity when resilvering + * so we can write it out to the failed device + * later. + */ if (parity_errors + parity_untried < - rm->rm_firstdatacol) { + rm->rm_firstdatacol || + (zio->io_flags & ZIO_FLAG_RESILVER)) { n = raidz_parity_verify(zio, rm); unexpected_errors += n; ASSERT(parity_errors + n <= @@ -925,8 +935,12 @@ vdev_raidz_io_done(zio_t *zio) * perform the reconstruction, but this should * be a relatively uncommon case, and can be * optimized if it becomes a problem. + * We also regenerate parity when resilvering + * so we can write it out to the failed device + * later. */ - if (parity_errors < rm->rm_firstdatacol - 1) { + if (parity_errors < rm->rm_firstdatacol - 1 || + (zio->io_flags & ZIO_FLAG_RESILVER)) { n = raidz_parity_verify(zio, rm); unexpected_errors += n; ASSERT(parity_errors + n <= diff --git a/sys/contrib/opensolaris/uts/common/fs/zfs/vdev_raidz.c b/sys/contrib/opensolaris/uts/common/fs/zfs/vdev_raidz.c index 08df7e09ba08..0c866307653b 100644 --- a/sys/contrib/opensolaris/uts/common/fs/zfs/vdev_raidz.c +++ b/sys/contrib/opensolaris/uts/common/fs/zfs/vdev_raidz.c @@ -867,8 +867,18 @@ vdev_raidz_io_done(zio_t *zio) case 0: if (zio_checksum_error(zio) == 0) { zio->io_error = 0; + + /* + * If we read parity information (unnecessarily + * as it happens since no reconstruction was + * needed) regenerate and verify the parity. + * We also regenerate parity when resilvering + * so we can write it out to the failed device + * later. + */ if (parity_errors + parity_untried < - rm->rm_firstdatacol) { + rm->rm_firstdatacol || + (zio->io_flags & ZIO_FLAG_RESILVER)) { n = raidz_parity_verify(zio, rm); unexpected_errors += n; ASSERT(parity_errors + n <= @@ -925,8 +935,12 @@ vdev_raidz_io_done(zio_t *zio) * perform the reconstruction, but this should * be a relatively uncommon case, and can be * optimized if it becomes a problem. + * We also regenerate parity when resilvering + * so we can write it out to the failed device + * later. */ - if (parity_errors < rm->rm_firstdatacol - 1) { + if (parity_errors < rm->rm_firstdatacol - 1 || + (zio->io_flags & ZIO_FLAG_RESILVER)) { n = raidz_parity_verify(zio, rm); unexpected_errors += n; ASSERT(parity_errors + n <=