Bug #7982
closedzfstest -a destroys rpool on IDE disks and should strip partition numbers
100%
Description
Background:¶
The OmniOS installer does not detect virtio disks, so my virtual
OmniOS rpool running under SmartOS KVM is on ide0-hd0
.
Runing zfstest -a
in that OmniOS VM destroys the rpool. (I was lucky
enough to snapshot the zvol before trying zfstest, no damage done)
Analysis:¶
The code which sets $all_disks accepts everything starting with c[0-9]
(zfstest.ksh:40) as disk, but the awk expression which detects disks
used in pools requires disk to start with c[0-9]*t[0-9]*d[0-0]
(zfstest.ksh:42). IDE disks have no target number so they are not
added to $used_disks and end up in the list of disks to use for the
tests.
Fix¶
Making the target number optional fixes this. While here also strip
partition numbers (p[0-9]+) as already done for slice
numbers. Partition numbers may exist in the wild.
Testing¶
Successfully ran zftest with the patch applied, rpool survived ;-),
three unused virtio disks where all detected and used.
Tested awk regexp with /usr/bin/awk, /usr/gnu/bin/awk and
/usr/xpg4/bin/awk, same for sed.
I'll open an openzfs PR on github and prepare a webrev.