[Bug 229829] [zfs] scrubbing prevents shutdown and slows down startup

From: <bugzilla-noreply_at_freebsd.org>
Date: Tue, 21 Jun 2022 14:33:25 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=229829

--- Comment #4 from Bryan Drewery <bdrewery@FreeBSD.org> ---
This seems simpler. I might find time to commit this.

diff --git usr.sbin/periodic/etc/daily/800.scrub-zfs
usr.sbin/periodic/etc/daily/800.scrub-zfs
index 8cca1ea4d949..474e070153e8 100755
--- usr.sbin/periodic/etc/daily/800.scrub-zfs
+++ usr.sbin/periodic/etc/daily/800.scrub-zfs
@@ -15,6 +15,13 @@ then
     source_periodic_confs
 fi

+doscrub() {
+       local pool="$1"
+
+       zfs set org.freebsd:last-scrub=$(date +%F.%T) "${pool}"
+       zpool scrub "${pool}"
+}
+
 : ${daily_scrub_zfs_default_threshold=35}

 case "$daily_scrub_zfs_enable" in
@@ -55,9 +62,7 @@ case "$daily_scrub_zfs_enable" in
                        _pool_threshold=${daily_scrub_zfs_default_threshold}
                fi

-               _last_scrub=$(zpool history ${pool} | \
-                   egrep "^[0-9\.\:\-]{19} zpool scrub ${pool}\$" | tail -1 |\
-                   cut -d ' ' -f 1)
+               _last_scrub=$(zfs get -s local -H -o value
org.freebsd:last-scrub ${pool})
                if [ -z "${_last_scrub}" ]; then
                        # creation time of the pool if no scrub was done
                        _last_scrub=$(zpool history ${pool} | \
@@ -88,12 +93,12 @@ case "$daily_scrub_zfs_enable" in
                                ;;
                        *"none requested"*)
                                echo "   starting first scrub (since reboot) of
pool '${pool}':"
-                               zpool scrub ${pool}
+                               doscrub ${pool}
                                [ $rc -eq 0 ] && rc=1
                                ;;
                        *)
                                echo "   starting scrub of pool '${pool}':"
-                               zpool scrub ${pool}
+                               doscrub ${pool}
                                [ $rc -eq 0 ] && rc=1
                                ;;
                esac

-- 
You are receiving this mail because:
You are the assignee for the bug.