misc/156659: periodic/daily/800.scrub-zfs fails on pool names
containing '-'
Jason J. Hellenthal
jhell at DataIX.net
Tue Apr 26 22:10:11 UTC 2011
The following reply was made to PR misc/156659; it has been noted by GNATS.
From: "Jason J. Hellenthal" <jhell at DataIX.net>
To: Jakob Alvermark <jakob.alvermark at bsdlabs.com>
Cc: freebsd-gnats-submit at freebsd.org
Subject: Re: misc/156659: periodic/daily/800.scrub-zfs fails on pool names
containing '-'
Date: Tue, 26 Apr 2011 18:07:31 -0400
--E39vaYmALEf/7YXx
Content-Type: multipart/mixed; boundary="OXfL5xGRrasGEqWY"
Content-Disposition: inline
--OXfL5xGRrasGEqWY
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
Jakob,
I have looked over your report of this. Thank you, I had a feeling this
was going to come up sooner or later since zpool(8) does not restrict
the name of the pool to not use hyphens and it shouldn't by all means.
I have created the following patch [1] and would be pleased if you could
test it out for me.
Log:
This patch changes the syntax for which pools with hyphens are parsed
and removes the daily_zfs_scrub_{pool}_threshold and includes that into
daily_scrub_zfs_pools.
The values are as such:
poolname:{threshold_value}
Where:
daily_scrub_zfs_default_threshold=3D"30"
daily_scrub_zfs_pools=3D"foobar:10 fu-bar:20 fu_bar:30 fubar54:5 fu-bar3:5
fu_bar7:5 fubar fu-bar fu_bar"
Equals:
Threshold =3D 10, for pool value foobar:10
Threshold =3D 20, for pool value fu-bar:20
Threshold =3D 30, for pool value fu_bar:30
Threshold =3D 5, for pool value fubar54:5
Threshold =3D 5, for pool value fu-bar3:5
Threshold =3D 5, for pool value fu_bar7:5
Threshold =3D 30, for pool value fubar
Threshold =3D 30, for pool value fu-bar
Threshold =3D 30, for pool value fu_bar
Since we cannot get around easily the fact that "FOO-BAR" is not a valid
variable name in sh(1) or any other shells I see this as an easy way to
accommodate for the variety of pool names that could be present on any
given system with ZFS since pool names cannot be restricted to not use
hyphens.
This patch will be updated further to change the appropriate manual pages
once further testing has been received.
Patches:
1). http://patches.jhell.googlecode.com/hg/800.scrub-zfs_hyphen.patch
This has been BCC'd to bug-followup@
--=20
Regards, (jhell)
Jason Hellenthal
--OXfL5xGRrasGEqWY
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment; filename="800.scrub-zfs_hyphen.patch"
Content-Transfer-Encoding: quoted-printable
# HG changeset patch
# Parent 532318f98505734384e742ee975e00a33d901ee6
misc/156659: periodic/daily/800.scrub-zfs fails on pool names containing a =
hyphen
diff -r 532318f98505 etc/periodic/daily/800.scrub-zfs
--- a/etc/periodic/daily/800.scrub-zfs
+++ b/etc/periodic/daily/800.scrub-zfs
@@ -27,10 +27,13 @@
fi
=20
for pool in ${daily_scrub_zfs_pools}; do
+
+ _pool_name=3D$(echo $pool |cut -f1 -d: |sed 's/://')
+
# sanity check
- _status=3D$(zpool list "${pool}" 2> /dev/null)
+ _status=3D$(zpool list "${_pool_name}" 2> /dev/null)
if [ $? -ne 0 ]; then
- echo " WARNING: pool '${pool}' specified in"
+ echo " WARNING: pool ${_pool_name} specified in"
echo " '/etc/periodic.conf:daily_scrub_zfs_pools'"
echo " does not exist"
continue
@@ -38,7 +41,7 @@
_status=3D${_status##*$newline}
case ${_status} in
*FAULTED*)
- echo "Skipping faulted pool: ${pool}"
+ echo "Skipping faulted pool: ${_pool_name}"
continue ;;
esac
=20
@@ -46,17 +49,17 @@
rc=3D0
=20
# determine how many days shall be between scrubs
- eval _pool_threshold=3D\${daily_scrub_zfs_${pool}_threshold}
- if [ -z "${_pool_threshold}" ];then
+ _pool_threshold=3D$(echo $pool |cut -f2 -d: |grep -v [aA-zZ])
+ if [ ! -n "${_pool_threshold}" ]; then
_pool_threshold=3D${daily_scrub_zfs_default_threshold}
fi
=20
- _last_scrub=3D$(zpool history ${pool} | \
- egrep "^[0-9\.\:\-]{19} zpool scrub ${pool}\$" | tail -1 |\
+ _last_scrub=3D$(zpool history ${_pool_name} | \
+ egrep "^[0-9\.\:\-]{19} zpool scrub ${_pool_name}\$" | tail -1 |\
cut -d ' ' -f 1)
if [ -z "${_last_scrub}" ]; then
# creation time of the pool if no scrub was done
- _last_scrub=3D$(zpool history ${pool} | \
+ _last_scrub=3D$(zpool history ${_pool_name} | \
sed -ne '2s/ .*$//p')
fi
=20
@@ -64,27 +67,27 @@
_scrub_diff=3D$(expr -e \( $(date +%s) - \
$(date -j -f %F.%T ${_last_scrub} +%s) \) / 60 / 60 / 24)
if [ ${_scrub_diff} -lt ${_pool_threshold} ]; then
- echo " skipping scrubbing of pool '${pool}':"
+ echo " skipping scrubbing of pool '${_pool_name}':"
echo " last scrubbing is ${_scrub_diff} days ago, threshold is set=
to ${_pool_threshold} days"
continue
fi
=20
- _status=3D"$(zpool status ${pool} | grep scrub:)"
+ _status=3D"$(zpool status ${_pool_name} | grep scrub:)"
case "${_status}" in
*"scrub in progress"*)
- echo " scrubbing of pool '${pool}' already in progress, skipping:"
+ echo " scrubbing of pool '${_pool_name}' already in progress, skippi=
ng:"
;;
*"none requested"*)
- echo " starting first scrub (since reboot) of pool '${pool}':"
- zpool scrub ${pool}
+ echo " starting first scrub (since reboot) of pool '${_pool_name}':"
+ zpool scrub ${_pool_name}
;;
*)
- echo " starting scrub of pool '${pool}':"
- zpool scrub ${pool}
+ echo " starting scrub of pool '${_pool_name}':"
+ zpool scrub ${_pool_name}
;;
esac
=20
- echo " consult 'zpool status ${pool}' for the result"
+ echo " consult 'zpool status ${_pool_name}' for the result"
done
;;
=20
--OXfL5xGRrasGEqWY--
--E39vaYmALEf/7YXx
Content-Type: application/pgp-signature
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.17 (FreeBSD)
Comment: http://bit.ly/0x89D8547E
iQEcBAEBAgAGBQJNt0IiAAoJEJBXh4mJ2FR+YBQH/1uDQrgfw7PegwHl8krF3WLH
DvlfmIQ5CJeGX1o9T+RWK39G3O0p7eFeQlPFi2UMUK98nc752kk7dISzTkoZ0WHj
OSKn92OSOYd10TJO3nZEpdYjFtYj0CpUfb7b/uGvYdaxaJVLMU2pQ/QA6MCHBmXI
Zr5EFWSDkipoQK4V7OlrLcKFMZVr4f77/iOEHUW4OEx6xB4TiwYShLVaW26yqeyD
BYr9RGztF7uG0Dy5QEh93SegZfG4oImMsJJ7ywraJ/yV6pMRumydlxqyWx830F91
l80UsKwe4YE2rpk5Fo4UpnqUPMi3ESLsbycjg7XGivA4aq1rAWhEh/7WD4j/91g=
=o0XQ
-----END PGP SIGNATURE-----
--E39vaYmALEf/7YXx--
More information about the freebsd-bugs
mailing list