From 0647ec13580b25f2d25d5e3f25c17d8a187a119e Mon Sep 17 00:00:00 2001 From: Nathaniel Wesley Filardo Date: Sun, 4 Jul 2021 14:38:17 +0100 Subject: [PATCH] vdev_mirror: when resilvering, try reading first From experience, resilvers can make it most of the way through and die for one reason or another. Optimistically, then, fling reads at devices being resilvered and respond to checksum mismatches rather than always writing. As this is a kind of nop-write, and out of an abundnace of caution, restrict this to checksum types strong enough to be considered good enough. (This, notably, excludes fletcher4, which is always used for pool metadata.) Signed-off-by: Nathaniel Wesley Filardo --- module/zfs/vdev_mirror.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/module/zfs/vdev_mirror.c b/module/zfs/vdev_mirror.c index 106678a8708e..07189b874f2b 100644 --- a/module/zfs/vdev_mirror.c +++ b/module/zfs/vdev_mirror.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include @@ -637,8 +638,15 @@ vdev_mirror_io_start(zio_t *zio) } if (zio->io_type == ZIO_TYPE_READ) { - if (zio->io_bp != NULL && - (zio->io_flags & ZIO_FLAG_SCRUB) && !mm->mm_resilvering) { + boolean_t have_checksum = zio->io_bp != NULL; + boolean_t is_scrub = have_checksum && + (zio->io_flags & ZIO_FLAG_SCRUB) && + !mm->mm_resilvering; + boolean_t resilver_read = have_checksum && + (zio->io_flags & (ZIO_FLAG_SCRUB | ZIO_FLAG_RESILVER)) && + (zio_checksum_table[BP_GET_CHECKSUM(zio->io_bp)].ci_flags & + ZCHECKSUM_FLAG_NOPWRITE); + if (is_scrub || resilver_read) { /* * For scrubbing reads (if we can verify the * checksum here, as indicated by io_bp being