Closed ghost closed 9 years ago
@dajhorn Do you see any such problem on Ubuntu? Do you depend on gawk (I don't)?
@pinek Thanx for moving it, but I might actually be wrong about having it here, but on the other hand it's an easier fix to put the dependency in the package instead of making sure that /lib/udev/vdev_id
works correctly in ZoL... ?
However, I'm not having any trouble using mawk on my Debian GNU/Linux Wheezy machine
# dpkg -l \*awk\*
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-=================================-=====================-=====================-========================================================================
un awk <none> (no description available)
un gawk <none> (no description available)
ii mawk 1.3.3-17 amd64 a pattern scanning and text processing language
# which awk
/usr/bin/awk
# ll /usr/bin/awk
lrwxrwxrwx 1 root root 21 Feb 4 2014 /usr/bin/awk -> /etc/alternatives/awk*
# ll /etc/alternatives/awk
lrwxrwxrwx 1 root root 13 Feb 4 2014 /etc/alternatives/awk -> /usr/bin/mawk*
# cat /etc/zfs/vdev_id.conf
alias disk_1a scsi-SATA_VBOX_HARDDISK_VB1f45d95c-477fd9c6
alias disk_1b scsi-SATA_VBOX_HARDDISK_VBa23b735b-e12dbf0c
alias disk_2a scsi-SATA_VBOX_HARDDISK_VB00c23763-14860ab9
alias disk_2b scsi-SATA_VBOX_HARDDISK_VBd15b7714-c746e03e
alias disk_3a scsi-SATA_VBOX_HARDDISK_VBe7e12ad6-7394c614
alias disk_3b scsi-SATA_VBOX_HARDDISK_VB69234b2a-d52afc22
alias disk_4a scsi-SATA_VBOX_HARDDISK_VBee9d66a1-edf52bff
# zpool status
pool: rpool
state: ONLINE
scan: none requested
config:
NAME STATE READ WRITE CKSUM
rpool ONLINE 0 0 0
disk_1a ONLINE 0 0 0
disk_1b ONLINE 0 0 0
errors: No known data errors
@dajhorn Do you see any such problem on Ubuntu?
That expression is good with gawk-4.1.1 and bad with mawk-1.3.3.
Do you depend on gawk (I don't)?
No, which means that this is probably a bug. It could be related to zfsonlinux/pkg-zfs#130 reported earlier by @gbkersey.
The offending regular expression could be fixed to work with either mawk or gawk. This seems to work:
--- /lib/udev/vdev_id 2014-09-12 11:05:28.000000000 -0700
+++ vdev_id 2014-12-17 10:41:24.187649414 -0800
@@ -116,7 +116,7 @@
local MAPPED_SLOT=
MAPPED_SLOT=`awk "\\$1 == \"slot\" && \\$2 == ${LINUX_SLOT} && \
- \\$4 ~ /^(${CHANNEL}|)$/ { print \\$3; exit }" $CONFIG`
+ \\$4 ~ /^(${CHANNEL}|\'\')$/ { print \\$3; exit }" $CONFIG`
if [ -z "$MAPPED_SLOT" ] ; then
MAPPED_SLOT=$LINUX_SLOT
fi
That expression is good with gawk-4.1.1 and bad with mawk-1.3.3.
Worked for me on mawk-1.3.3...
@nedbass, I get this on Utopic with the busybox that runs most of the pre-init:
$ echo '""' | busybox awk '$1 ~ /^(A|\"\")$/ {print "TRUE";}'
TRUE
$ echo '' | busybox awk '$1 ~ /^(A|\"\")$/ {print "TRUE";}'
TRUE
$ echo '""' | busybox awk '$1 ~ /^(A|"")$/ {print "TRUE";}'
TRUE
$ echo '' | busybox awk '$1 ~ /^(A|"")$/ {print "TRUE";}'
Is this expected behavior? -- It seems like the literal quote handling is ambiguous.
@dajhorn my original diff with double-quotes was broken, as you discovered. I updated it to use single quotes which seem to work as intended.
The quoting is problematic in any form I've tried. Instead I moved the ^$
anchors inside the alternation.
Thanks guys, the updated patch appears to work properly with both mawk
and gawk
. I've merged it as:
2d9d57b vdev_id: use mawk-compatible regular expression
I originally opened this at https://github.com/zfsonlinux/zfs/issues/2965, but was told it belonged here, so I guess we'll see.
After a ZFS upgrade on a Debian 7 server, my JBOD slot mappings defined in /etc/zfs/vdev_id.conf were broken. When I ran the vdev_id script manually on a device, I got the following:
The device should actually be mapped to A10 (linux slot 9 mapped to A10), but the awk error prevents the mapping and so the bay_identifier value is used instead. I have an older ZFS version installed on CentOS, and I copied it to this same Debian server, and that scripted worked fine. It appears the change for issue #2056 introduced this problem (specifically this diff: https://github.com/nedbass/zfs/commit/533d96afc85cb102f37eedded5025f5c23c4247a#diff-081bd452e1418e3d0dfab42b86a44142L115). I did a bit more investigation and noticed that the versions of awk are different between Debian and CentOS, the former being "mawk" while the latter is "gawk". Apparently the new syntax is not portable between them. After I installed gawk on the Debian server, the error is gone and my mappings are correct again:
I would have suggested adding a gawk dependency to the Debian package, but not sure that will fly. I have found some similar issues that avoided doing so: https://github.com/zfsonlinux/zfs/issues/76 (gawk dependency was removed) and https://github.com/zfsonlinux/zfs/issues/259 (awk usage was replaced)