FreeBSD Bugzilla – Attachment 247294 Details for
Bug 275965
periodic: add a daily zfs trim
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
patch
zfstrim.diff (text/plain), 3.11 KB, created by
Lexi Winter
on 2023-12-27 13:48:10 UTC
(
hide
)
Description:
patch
Filename:
MIME Type:
Creator:
Lexi Winter
Created:
2023-12-27 13:48:10 UTC
Size:
3.11 KB
patch
obsolete
>diff --git a/share/man/man5/periodic.conf.5 b/share/man/man5/periodic.conf.5 >index 3ad39070839f..afa98506e612 100644 >--- a/share/man/man5/periodic.conf.5 >+++ b/share/man/man5/periodic.conf.5 >@@ -634,6 +634,15 @@ The same as > .Va daily_scrub_zfs_default_threshold > but specific to the pool > .Ao Ar poolname Ac Ns . >+.It Va daily_trim_zfs_enable >+.Pq Vt bool >+Set to >+.Dq Li YES >+if you want to run a zfs trim daily. >+.It Va daily_trim_zfs_pools >+.Pq Vt str >+A space separated list of names of zfs pools to trim. >+If the list is empty or not set, all zfs pools are trimmed. > .It Va daily_local > .Pq Vt str > Set to a list of extra scripts that should be run after all other >diff --git a/usr.sbin/periodic/etc/daily/801.trim-zfs b/usr.sbin/periodic/etc/daily/801.trim-zfs >new file mode 100755 >index 000000000000..fe7e76520976 >--- /dev/null >+++ b/usr.sbin/periodic/etc/daily/801.trim-zfs >@@ -0,0 +1,65 @@ >+#!/bin/sh >+# >+# >+ >+# If there is a global system configuration file, suck it in. >+# >+ >+newline=" >+" # A single newline >+ >+if [ -r /etc/defaults/periodic.conf ] >+then >+ . /etc/defaults/periodic.conf >+ source_periodic_confs >+fi >+ >+case "$daily_trim_zfs_enable" in >+ [Yy][Ee][Ss]) >+ echo >+ echo 'Trimming of zfs pools:' >+ >+ if [ -z "${daily_trim_zfs_pools}" ]; then >+ daily_trim_zfs_pools="$(zpool list -H -o name)" >+ fi >+ >+ rc=0 >+ for pool in ${daily_trim_zfs_pools}; do >+ # sanity check >+ _status=$(zpool list "${pool}" 2> /dev/null) >+ if [ $? -ne 0 ]; then >+ rc=2 >+ echo " WARNING: pool '${pool}' specified in" >+ echo " '/etc/periodic.conf:daily_trim_zfs_pools'" >+ echo " does not exist" >+ continue >+ fi >+ _status=${_status##*$newline} >+ case ${_status} in >+ *FAULTED*) >+ rc=3 >+ echo "Skipping faulted pool: ${pool}" >+ continue ;; >+ *UNAVAIL*) >+ rc=4 >+ echo "Skipping unavailable pool: ${pool}" >+ continue ;; >+ esac >+ >+ zpool status ${pool} | grep -q '(trimming)' >+ if [ $? -eq 1 ]; then >+ echo " starting trim of pool '${pool}'" >+ zpool trim ${pool} >+ [ $rc -eq 0 ] && rc=1 >+ else >+ echo " trim of pool '${pool}' already in progress, skipping" >+ fi >+ done >+ ;; >+ >+ *) >+ rc=0 >+ ;; >+esac >+ >+exit $rc >diff --git a/usr.sbin/periodic/etc/daily/Makefile b/usr.sbin/periodic/etc/daily/Makefile >index 4eabc0bb1d52..3bf4601f5145 100644 >--- a/usr.sbin/periodic/etc/daily/Makefile >+++ b/usr.sbin/periodic/etc/daily/Makefile >@@ -60,7 +60,8 @@ SENDMAILPACKAGE= sendmail > .if ${MK_ZFS} != "no" > CONFS+= 223.backup-zfs \ > 404.status-zfs \ >- 800.scrub-zfs >+ 800.scrub-zfs \ >+ 801.trim-zfs > .endif > > .include <bsd.prog.mk> >diff --git a/usr.sbin/periodic/periodic.conf b/usr.sbin/periodic/periodic.conf >index 8a69a7e703aa..5850dd7fa1c6 100644 >--- a/usr.sbin/periodic/periodic.conf >+++ b/usr.sbin/periodic/periodic.conf >@@ -178,6 +178,10 @@ daily_scrub_zfs_pools="" # empty string selects all pools > daily_scrub_zfs_default_threshold="35" # days between scrubs > #daily_scrub_zfs_${poolname}_threshold="35" # pool specific threshold > >+# 801.trim-zfs >+daily_trim_zfs_enable="NO" >+daily_trim_zfs_pools="" # empty string selects all pools >+ > # 999.local > daily_local="/etc/daily.local" # Local scripts >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 275965
: 247294 |
250113
|
252519