Add cleanup option -c to zconfig.sh
Several folks have now remarked that when the regression tests fail they leave a mess behind. This was done intentionally at the time to facilitate debugging the wreckage. However, this also means that you may need to do some manual cleanup such as removing the loopback devices before re-running the tests. To simplify this proceedure I've added the '-c' option to zconfig.sh which will attempt to cleanup the mess from a previous test before starting. This is somewhat dangerous because it must guess as to which loopback devices you were using. But this risk is fairly minimal because devices which are currently still is use can not be cleaned up. And because only devices with 'zpool' in the name are considered for removal. That said if your running parallel copies of say zconfig.sh this may cause you some trouble.
This commit is contained in:
parent
019953e0b7
commit
a6644f49a5
|
@ -15,6 +15,7 @@ MODULES=(zlib_deflate spl splat zavl znvpair zunicode zcommon zfs)
|
|||
fi
|
||||
|
||||
PROG="<define PROG>"
|
||||
CLEANUP=
|
||||
VERBOSE=
|
||||
VERBOSE_FLAG=
|
||||
FORCE=
|
||||
|
@ -207,6 +208,24 @@ unused_loop_device() {
|
|||
die "Error: Unable to find unused loopback device"
|
||||
}
|
||||
|
||||
#
|
||||
# This can be slightly dangerous because the loop devices we are
|
||||
# cleanup up may not be ours. However, if the devices are currently
|
||||
# in use we will not be able to remove them, and we only remove
|
||||
# devices which include 'zpool' in the name. So any damage we might
|
||||
# do should be limited to other zfs related testing.
|
||||
#
|
||||
cleanup_loop_devices() {
|
||||
local TMP_FILE=`mktemp`
|
||||
|
||||
${LOSETUP} -a | tr -d '()' >${TMP_FILE}
|
||||
${AWK} -F":" -v losetup="$LOSETUP" \
|
||||
'/zpool/ { system("losetup -d "$1) }' ${TMP_FILE}
|
||||
${AWK} -F" " '/zpool/ { system("rm -f "$3) }' ${TMP_FILE}
|
||||
|
||||
rm -f ${TMP_FILE}
|
||||
}
|
||||
|
||||
#
|
||||
# The following udev helper functions assume that the provided
|
||||
# udev rules file will create a /dev/disk/zpool/<CHANNEL><RANK>
|
||||
|
|
|
@ -16,7 +16,7 @@ PROG=zconfig.sh
|
|||
usage() {
|
||||
cat << EOF
|
||||
USAGE:
|
||||
$0 [hv]
|
||||
$0 [hvc]
|
||||
|
||||
DESCRIPTION:
|
||||
ZFS/ZPOOL configuration tests
|
||||
|
@ -24,11 +24,12 @@ DESCRIPTION:
|
|||
OPTIONS:
|
||||
-h Show this message
|
||||
-v Verbose
|
||||
-c Cleanup lo+file devices at start
|
||||
|
||||
EOF
|
||||
}
|
||||
|
||||
while getopts 'hv' OPTION; do
|
||||
while getopts 'hvc?' OPTION; do
|
||||
case $OPTION in
|
||||
h)
|
||||
usage
|
||||
|
@ -37,6 +38,9 @@ while getopts 'hv' OPTION; do
|
|||
v)
|
||||
VERBOSE=1
|
||||
;;
|
||||
c)
|
||||
CLEANUP=1
|
||||
;;
|
||||
?)
|
||||
usage
|
||||
exit
|
||||
|
@ -48,6 +52,12 @@ if [ $(id -u) != 0 ]; then
|
|||
die "Must run as root"
|
||||
fi
|
||||
|
||||
# Perform pre-cleanup is requested
|
||||
if [ ${CLEANUP} ]; then
|
||||
cleanup_loop_devices
|
||||
rm -f /tmp/zpool.cache.*
|
||||
fi
|
||||
|
||||
zconfig_partition() {
|
||||
local DEVICE=$1
|
||||
local START=$2
|
||||
|
|
Loading…
Reference in New Issue