xref: /freebsd/sys/contrib/openzfs/cmd/zed/zed.d/resilver_finish-start-scrub.sh (revision cfd6422a5217410fbd66f7a7a8a64d9d85e61229)
1#!/bin/sh
2# resilver_finish-start-scrub.sh
3# Run a scrub after a resilver
4#
5# Exit codes:
6# 1: Internal error
7# 2: Script wasn't enabled in zed.rc
8# 3: Scrubs are automatically started for sequential resilvers
9[ -f "${ZED_ZEDLET_DIR}/zed.rc" ] && . "${ZED_ZEDLET_DIR}/zed.rc"
10. "${ZED_ZEDLET_DIR}/zed-functions.sh"
11
12[ "${ZED_SCRUB_AFTER_RESILVER}" = "1" ] || exit 2
13[ "${ZEVENT_RESILVER_TYPE}" != "sequential" ] || exit 3
14[ -n "${ZEVENT_POOL}" ] || exit 1
15[ -n "${ZEVENT_SUBCLASS}" ] || exit 1
16zed_check_cmd "${ZPOOL}" || exit 1
17
18zed_log_msg "Starting scrub after resilver on ${ZEVENT_POOL}"
19"${ZPOOL}" scrub "${ZEVENT_POOL}"
20