Optimize RAIDZ expansion
[zfs.git] / cmd / zed / zed.d / resilver_finish-start-scrub.sh
blobcafce6fde54be5942df836790f0b019f7ebba57e
1 #!/bin/sh
2 # shellcheck disable=SC2154
3 # resilver_finish-start-scrub.sh
4 # Run a scrub after a resilver
6 # Exit codes:
7 # 1: Internal error
8 # 2: Script wasn't enabled in zed.rc
9 # 3: Scrubs are automatically started for sequential resilvers
10 [ -f "${ZED_ZEDLET_DIR}/zed.rc" ] && . "${ZED_ZEDLET_DIR}/zed.rc"
11 . "${ZED_ZEDLET_DIR}/zed-functions.sh"
13 [ "${ZED_SCRUB_AFTER_RESILVER}" = "1" ] || exit 2
14 [ "${ZEVENT_RESILVER_TYPE}" != "sequential" ] || exit 3
15 [ -n "${ZEVENT_POOL}" ] || exit 1
16 [ -n "${ZEVENT_SUBCLASS}" ] || exit 1
17 zed_check_cmd "${ZPOOL}" || exit 1
19 zed_log_msg "Starting scrub after resilver on ${ZEVENT_POOL}"
20 "${ZPOOL}" scrub "${ZEVENT_POOL}"