]> git.proxmox.com Git - mirror_zfs.git/commit
Resilver restarts unnecessarily when it encounters errors
authorJohn Poduska <jpoduska@datto.com>
Wed, 13 May 2020 17:54:27 +0000 (13:54 -0400)
committerGitHub <noreply@github.com>
Wed, 13 May 2020 17:54:27 +0000 (10:54 -0700)
commit41035a049643ff7083a6cb6cd43b8eb70a7d18a1
tree121cec91a2b10ca6e9fb7d376a7599d47f4aee8c
parentb29e31d80d6cb78dbd889e9b529333944b4c3ba1
Resilver restarts unnecessarily when it encounters errors

When a resilver finishes, vdev_dtl_reassess is called to hopefully
excise DTL_MISSING (amongst other things). If there are errors during
the resilver, they are tracked in DTL_SCRUB, as spelled out in the
block comment in vdev.c. DTL_SCRUB is in-core only, so it can only
be used if the pool was online for the whole resilver. This state is
tracked with the spa_scrub_started flag, which only gets set when
the scan is initialized. Unfortunately, this flag gets cleared right
before vdev_dtl_reassess gets called, so if there are any errors
during the scan, DTL_MISSING will never get excised and the resilver
will just continually restart. This fix simply moves clearing that
flag until after the call to vdev_dtl_reasses.

In addition, if a pool is imported and already has scn_errors > 0,
this change will restart the resilver immediately instead of doing
the rest of the scan and then restarting it from the beginning. On
the other hand, if scn_errors == 0 at import, then no errors have
been encountered so far, so the spa_scrub_started flag can be safely
set.

A test has been added to verify that resilver does not restart when
relevant DTL's are available.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Paul Zuchowski <pzuchowski@datto.com>
Signed-off-by: John Poduska <jpoduska@datto.com>
Closes #10291
module/zfs/dsl_scan.c
module/zfs/vdev.c
tests/runfiles/common.run
tests/zfs-tests/include/tunables.cfg
tests/zfs-tests/tests/functional/resilver/Makefile.am
tests/zfs-tests/tests/functional/resilver/resilver_restart_002.ksh [new file with mode: 0755]