View | Details | Raw Unified | Return to bug 275965 | Differences between
and this patch

Collapse All | Expand All

(-)b/share/man/man5/periodic.conf.5 (+9 lines)
Lines 634-639 The same as Link Here
634
.Va daily_scrub_zfs_default_threshold
634
.Va daily_scrub_zfs_default_threshold
635
but specific to the pool
635
but specific to the pool
636
.Ao Ar poolname Ac Ns .
636
.Ao Ar poolname Ac Ns .
637
.It Va daily_trim_zfs_enable
638
.Pq Vt bool
639
Set to
640
.Dq Li YES
641
if you want to run a zfs trim daily.
642
.It Va daily_trim_zfs_pools
643
.Pq Vt str
644
A space separated list of names of zfs pools to trim.
645
If the list is empty or not set, all zfs pools are trimmed.
637
.It Va daily_local
646
.It Va daily_local
638
.Pq Vt str
647
.Pq Vt str
639
Set to a list of extra scripts that should be run after all other
648
Set to a list of extra scripts that should be run after all other
(-)b/usr.sbin/periodic/etc/daily/801.trim-zfs (+65 lines)
Added Link Here
1
#!/bin/sh
2
#
3
#
4
5
# If there is a global system configuration file, suck it in.
6
#
7
8
newline="
9
" # A single newline
10
11
if [ -r /etc/defaults/periodic.conf ]
12
then
13
    . /etc/defaults/periodic.conf
14
    source_periodic_confs
15
fi
16
17
case "$daily_trim_zfs_enable" in
18
    [Yy][Ee][Ss])
19
	echo
20
	echo 'Trimming of zfs pools:'
21
22
	if [ -z "${daily_trim_zfs_pools}" ]; then
23
		daily_trim_zfs_pools="$(zpool list -H -o name)"
24
	fi
25
26
	rc=0
27
	for pool in ${daily_trim_zfs_pools}; do
28
		# sanity check
29
		_status=$(zpool list "${pool}" 2> /dev/null)
30
		if [ $? -ne 0 ]; then
31
			rc=2
32
			echo "   WARNING: pool '${pool}' specified in"
33
			echo "            '/etc/periodic.conf:daily_trim_zfs_pools'"
34
			echo "            does not exist"
35
			continue
36
		fi
37
		_status=${_status##*$newline}
38
		case ${_status} in
39
		*FAULTED*)
40
			rc=3
41
			echo "Skipping faulted pool: ${pool}"
42
			continue ;;
43
		*UNAVAIL*)
44
			rc=4
45
			echo "Skipping unavailable pool: ${pool}"
46
			continue ;;
47
		esac
48
49
		zpool status ${pool} | grep -q '(trimming)'
50
		if [ $? -eq 1 ]; then
51
			echo "    starting trim of pool '${pool}'"
52
			zpool trim ${pool}
53
			[ $rc -eq 0 ] && rc=1
54
		else
55
			echo "    trim of pool '${pool}' already in progress, skipping"
56
		fi
57
	done
58
	;;
59
60
    *)
61
	rc=0
62
	;;
63
esac
64
65
exit $rc
(-)b/usr.sbin/periodic/etc/daily/Makefile (-1 / +2 lines)
Lines 60-66 SENDMAILPACKAGE= sendmail Link Here
60
.if ${MK_ZFS} != "no"
60
.if ${MK_ZFS} != "no"
61
CONFS+=	223.backup-zfs \
61
CONFS+=	223.backup-zfs \
62
	404.status-zfs \
62
	404.status-zfs \
63
	800.scrub-zfs
63
	800.scrub-zfs  \
64
	801.trim-zfs
64
.endif
65
.endif
65
66
66
.include <bsd.prog.mk>
67
.include <bsd.prog.mk>
(-)b/usr.sbin/periodic/periodic.conf (+4 lines)
Lines 178-183 daily_scrub_zfs_pools="" # empty string selects all pools Link Here
178
daily_scrub_zfs_default_threshold="35"		# days between scrubs
178
daily_scrub_zfs_default_threshold="35"		# days between scrubs
179
#daily_scrub_zfs_${poolname}_threshold="35"	# pool specific threshold
179
#daily_scrub_zfs_${poolname}_threshold="35"	# pool specific threshold
180
180
181
# 801.trim-zfs
182
daily_trim_zfs_enable="NO"
183
daily_trim_zfs_pools=""				# empty string selects all pools
184
181
# 999.local
185
# 999.local
182
daily_local="/etc/daily.local"				# Local scripts
186
daily_local="/etc/daily.local"				# Local scripts
183
187

Return to bug 275965