1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-22 17:35:59 +03:00

tests: paralelize creation and teardown

To speedup initial construction and destruction of test devices
(mainly in case more then 1 is needed)  call dmsetup
in parallel.
This commit is contained in:
Zdenek Kabelac 2017-02-21 00:49:49 +01:00
parent 921d5972e8
commit d409fec079

View File

@ -405,17 +405,19 @@ teardown_devs_prefixed() {
fi
# Remove devices, start with closed (sorted by open count)
local remfail=no
# Run 'dmsetup remove' in parallel
rm -f REMOVE_FAILED
local need_udev_wait=0
init_udev_transaction
for dm in $(dm_info name --sort open | grep "$prefix"); do
dmsetup remove "$dm" &>/dev/null || remfail=yes
for dm in $(dm_info name --sort open,name | grep "$prefix"); do
dmsetup remove "$dm" &>/dev/null || touch REMOVE_FAILED &
need_udev_wait=1
done
wait
finish_udev_transaction
test $need_udev_wait -eq 0 || udev_wait
if test $remfail = yes; then
if test -f REMOVE_FAILED; then
local num_devs
local num_remaining_devs=999
while num_devs=$(dm_table | grep "$prefix" | wc -l) && \
@ -794,6 +796,7 @@ prepare_devs() {
local size=$(($devsize*2048)) # sectors
local count=0
rm -f CREATE_FAILED
init_udev_transaction
for i in $(seq 1 $n); do
local name="${PREFIX}$pvname$i"
@ -801,16 +804,18 @@ prepare_devs() {
DEVICES[$count]=$dev
count=$(( $count + 1 ))
echo 0 $size linear "$BACKING_DEV" $((($i-1)*$size + $shift)) > "$name.table"
if not dmsetup create -u "TEST-$name" "$name" "$name.table" &&
test -n "$LVM_TEST_BACKING_DEVICE";
then # maybe the backing device is too small for this test
dmsetup create -u "TEST-$name" "$name" "$name.table" || touch CREATE_FAILED &
test -f CREATE_FAILED && break;
done
wait
finish_udev_transaction
if test -f CREATE_FAILED -a -n "$LVM_TEST_BACKING_DEVICE"; then
LVM_TEST_BACKING_DEVICE=
rm -f BACKING_DEV
rm -f BACKING_DEV CREATE_FAILED
prepare_devs "$@"
return $?
fi
done
finish_udev_transaction
# non-ephemeral devices need to be cleared between tests
test -f LOOP || for d in ${DEVICES[@]}; do
@ -833,9 +838,11 @@ prepare_devs() {
# ( IFS=$'\n'; echo "${DEVICES[*]}" ) >DEVICES
echo "ok"
if test -e LOCAL_LVMETAD; then
for dev in "${DEVICES[@]}"; do
notify_lvmetad "$dev"
done
fi
}