2017-07-02 22:38:32 +03:00
#!/usr/bin/env bash
2015-04-03 11:41:33 +03:00
# Copyright (C) 2015 Red Hat, Inc. All rights reserved.
#
# This copyrighted material is made available to anyone wishing to use,
# modify, copy, or redistribute it subject to the terms and conditions
# of the GNU General Public License v.2.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
2016-01-21 13:49:46 +03:00
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2015-04-03 11:41:33 +03:00
# Check whether all available pvmove resume methods works as expected.
# lvchange is able to resume pvmoves in progress.
# 2 pvmove LVs in 2 VGs (1 per VG)
2016-02-23 01:13:42 +03:00
SKIP_WITH_LVMLOCKD = 1
2015-10-27 17:10:06 +03:00
SKIP_WITH_CLVMD = 1
2015-04-03 11:41:33 +03:00
. lib/inittest
aux prepare_pvs 4 30
vgcreate -s 128k $vg " $dev1 "
vgcreate -s 128k $vg1 " $dev2 "
pvcreate --metadatacopies 0 " $dev3 "
pvcreate --metadatacopies 0 " $dev4 "
vgextend $vg " $dev3 "
vgextend $vg1 " $dev4 "
# $1 resume fn
test_pvmove_resume( ) {
lvcreate -an -Zn -l30 -n $lv1 $vg
lvcreate -an -Zn -l30 -n $lv1 $vg1
2021-04-01 12:33:40 +03:00
aux delay_dev " $dev3 " 0 30 " $( get first_extent_sector " $dev3 " ) : "
2015-11-09 21:06:55 +03:00
test -e HAVE_DM_DELAY || { lvremove -f $vg $vg1 ; return 0; }
2021-04-01 12:33:40 +03:00
aux delay_dev " $dev4 " 0 30 " $( get first_extent_sector " $dev4 " ) : "
2015-04-03 11:41:33 +03:00
pvmove -i5 " $dev1 " &
PVMOVE = $!
2021-04-01 12:33:40 +03:00
aux wait_pvmove_lv_ready " $vg -pvmove0 "
kill $PVMOVE
test -e LOCAL_LVMPOLLD && aux prepare_lvmpolld
2015-04-03 11:41:33 +03:00
pvmove -i5 " $dev2 " &
PVMOVE = $!
2021-04-01 12:33:40 +03:00
aux wait_pvmove_lv_ready " $vg1 -pvmove0 "
kill $PVMOVE
2021-03-28 13:18:40 +03:00
test -e LOCAL_LVMPOLLD && aux prepare_lvmpolld
2015-04-03 11:41:33 +03:00
wait
2021-04-01 12:33:40 +03:00
aux remove_dm_devs " $vg - $lv1 " " $vg1 - $lv1 " " $vg -pvmove0 " " $vg1 -pvmove0 "
2015-04-03 11:41:33 +03:00
check lv_attr_bit type $vg /pvmove0 "p"
check lv_attr_bit type $vg1 /pvmove0 "p"
if test -e LOCAL_CLVMD ; then
# giveup all clvmd locks (faster then restarting clvmd)
# no deactivation happen, nodes are already removed
#vgchange -an $vg
# FIXME: However above solution has one big problem
# as clvmd starts to abort on internal errors on various
# errors, based on the fact pvmove is killed -9
# Restart clvmd
2017-07-10 11:40:09 +03:00
kill " $( < LOCAL_CLVMD) "
2015-04-03 11:41:33 +03:00
for i in $( seq 1 100) ; do
test $i -eq 100 && die "Shutdown of clvmd is too slow."
test -e " $CLVMD_PIDFILE " || break
sleep .1
done # wait for the pid removal
aux prepare_clvmd
fi
# call resume function (see below)
# with expected number of spawned
# bg polling as parameter
$1 2
2021-04-01 12:33:40 +03:00
aux enable_dev " $dev3 " " $dev4 "
2015-04-03 11:41:33 +03:00
2021-04-01 12:33:40 +03:00
for i in { 100..0} ; do
lvs -ao name $vg $vg1 | grep "\[pvmove" || break
2015-04-03 11:41:33 +03:00
sleep .1
done
2021-04-01 12:33:40 +03:00
# wait for 10 secs at max
test $i -eq 0 && die "Pvmove is too slow or does not progress."
2015-04-03 11:41:33 +03:00
2015-04-30 19:42:31 +03:00
aux kill_tagged_processes
2015-04-28 16:31:47 +03:00
2015-04-03 11:41:33 +03:00
lvremove -ff $vg $vg1
}
lvchange_single( ) {
2015-04-28 16:31:47 +03:00
LVM_TEST_TAG = " kill_me_ $PREFIX " lvchange -aey $vg /$lv1
LVM_TEST_TAG = " kill_me_ $PREFIX " lvchange -aey $vg1 /$lv1
2015-04-03 11:41:33 +03:00
2015-05-09 02:59:18 +03:00
if test -e LOCAL_LVMPOLLD; then
aux lvmpolld_dump | tee lvmpolld_dump.txt
aux check_lvmpolld_init_rq_count 1 " $vg /pvmove0 "
aux check_lvmpolld_init_rq_count 1 " $vg1 /pvmove0 "
else
2017-07-10 11:40:09 +03:00
test " $( aux count_processes_with_tag) " -eq $1
2015-05-09 02:59:18 +03:00
fi
2015-04-03 11:41:33 +03:00
}
lvchange_all( ) {
2015-04-28 16:31:47 +03:00
LVM_TEST_TAG = " kill_me_ $PREFIX " lvchange -aey $vg /$lv1 $vg1 /$lv1
2015-04-03 11:41:33 +03:00
2015-05-09 02:59:18 +03:00
if test -e LOCAL_LVMPOLLD; then
aux lvmpolld_dump | tee lvmpolld_dump.txt
aux check_lvmpolld_init_rq_count 1 " $vg /pvmove0 "
aux check_lvmpolld_init_rq_count 1 " $vg1 /pvmove0 "
else
2017-07-10 11:40:09 +03:00
test " $( aux count_processes_with_tag) " -eq $1
2015-05-09 02:59:18 +03:00
fi
2015-04-03 11:41:33 +03:00
}
vgchange_single( ) {
2015-04-28 16:31:47 +03:00
LVM_TEST_TAG = " kill_me_ $PREFIX " vgchange -aey $vg
LVM_TEST_TAG = " kill_me_ $PREFIX " vgchange -aey $vg1
2015-04-03 11:41:33 +03:00
2015-05-09 02:59:18 +03:00
if test -e LOCAL_LVMPOLLD; then
aux lvmpolld_dump | tee lvmpolld_dump.txt
aux check_lvmpolld_init_rq_count 1 " $vg /pvmove0 "
aux check_lvmpolld_init_rq_count 1 " $vg1 /pvmove0 "
else
2017-07-10 11:40:09 +03:00
test " $( aux count_processes_with_tag) " -eq " $1 "
2015-05-09 02:59:18 +03:00
fi
2015-04-03 11:41:33 +03:00
}
vgchange_all( ) {
2015-04-28 16:31:47 +03:00
LVM_TEST_TAG = " kill_me_ $PREFIX " vgchange -aey $vg $vg1
2015-04-03 11:41:33 +03:00
2015-05-09 02:59:18 +03:00
if test -e LOCAL_LVMPOLLD; then
aux lvmpolld_dump | tee lvmpolld_dump.txt
aux check_lvmpolld_init_rq_count 1 " $vg /pvmove0 "
aux check_lvmpolld_init_rq_count 1 " $vg1 /pvmove0 "
else
2017-07-10 11:40:09 +03:00
test " $( aux count_processes_with_tag) " -eq " $1 "
2015-05-09 02:59:18 +03:00
fi
2015-04-03 11:41:33 +03:00
}
pvmove_fg( ) {
2015-04-28 16:31:47 +03:00
# pvmove resume requires LVs active...
LVM_TEST_TAG = " kill_me_ $PREFIX " vgchange --config 'activation{polling_interval=10}' -aey --poll n $vg $vg1
2015-04-03 11:41:33 +03:00
2015-04-28 16:31:47 +03:00
# ...also vgchange --poll n must not spawn any bg processes...
2015-05-09 02:59:18 +03:00
if test -e LOCAL_LVMPOLLD; then
aux lvmpolld_dump | tee lvmpolld_dump.txt
aux check_lvmpolld_init_rq_count 0 " $vg /pvmove0 "
aux check_lvmpolld_init_rq_count 0 " $vg1 /pvmove0 "
else
2017-07-10 11:40:09 +03:00
test " $( aux count_processes_with_tag) " -eq 0
2015-05-09 02:59:18 +03:00
fi
2015-04-03 11:41:33 +03:00
2015-04-28 16:31:47 +03:00
# ...thus finish polling
2017-07-03 21:55:11 +03:00
get lv_field $vg name -a | grep -E "^\[?pvmove0"
get lv_field $vg1 name -a | grep -E "^\[?pvmove0"
2015-04-03 11:41:33 +03:00
# disable delay device
# fg pvmove would take ages to complete otherwise
aux enable_dev " $dev3 "
aux enable_dev " $dev4 "
2015-04-28 16:31:47 +03:00
pvmove
2015-04-03 11:41:33 +03:00
}
pvmove_bg( ) {
2015-04-28 16:31:47 +03:00
# pvmove resume requires LVs active...
LVM_TEST_TAG = " kill_me_ $PREFIX " vgchange --config 'activation{polling_interval=10}' -aey --poll n $vg $vg1
2015-04-03 11:41:33 +03:00
2015-04-28 16:31:47 +03:00
# ...also vgchange --poll n must not spawn any bg processes...
2015-05-09 02:59:18 +03:00
if test -e LOCAL_LVMPOLLD; then
aux lvmpolld_dump | tee lvmpolld_dump.txt
aux check_lvmpolld_init_rq_count 0 " $vg /pvmove0 "
aux check_lvmpolld_init_rq_count 0 " $vg1 /pvmove0 "
else
2017-07-10 11:40:09 +03:00
test " $( aux count_processes_with_tag) " -eq 0
2015-05-09 02:59:18 +03:00
fi
2015-04-03 11:41:33 +03:00
2015-04-28 16:31:47 +03:00
# ...thus finish polling
2017-07-03 21:55:11 +03:00
get lv_field $vg name -a | grep -E "^\[?pvmove0"
get lv_field $vg1 name -a | grep -E "^\[?pvmove0"
2015-04-03 11:41:33 +03:00
2015-04-28 16:31:47 +03:00
LVM_TEST_TAG = " kill_me_ $PREFIX " pvmove -b -i0
2015-04-03 11:41:33 +03:00
}
pvmove_fg_single( ) {
2015-04-28 16:31:47 +03:00
# pvmove resume requires LVs active...
LVM_TEST_TAG = " kill_me_ $PREFIX " vgchange --config 'activation{polling_interval=10}' -aey --poll n $vg
2015-04-03 11:41:33 +03:00
2015-04-28 16:31:47 +03:00
# ...also vgchange --poll n must not spawn any bg processes...
2015-05-09 02:59:18 +03:00
if test -e LOCAL_LVMPOLLD; then
aux lvmpolld_dump | tee lvmpolld_dump.txt
aux check_lvmpolld_init_rq_count 0 " $vg /pvmove0 "
aux check_lvmpolld_init_rq_count 0 " $vg1 /pvmove0 "
else
2017-07-10 11:40:09 +03:00
test " $( aux count_processes_with_tag) " -eq 0
2015-05-09 02:59:18 +03:00
fi
2015-04-03 11:41:33 +03:00
2015-04-28 16:31:47 +03:00
# ...thus finish polling
2017-07-03 21:55:11 +03:00
get lv_field $vg name -a | grep -E "^\[?pvmove0"
get lv_field $vg1 name -a | grep -E "^\[?pvmove0"
2015-04-03 11:41:33 +03:00
# disable delay device
# fg pvmove would take ages to complete otherwise
aux enable_dev " $dev3 "
aux enable_dev " $dev4 "
2015-04-28 16:31:47 +03:00
pvmove " $dev1 "
pvmove " $dev2 "
2015-04-03 11:41:33 +03:00
}
pvmove_bg_single( ) {
2015-04-28 16:31:47 +03:00
# pvmove resume requires LVs active...
LVM_TEST_TAG = " kill_me_ $PREFIX " vgchange --config 'activation{polling_interval=10}' -aey --poll n $vg
2015-04-03 11:41:33 +03:00
2015-04-28 16:31:47 +03:00
# ...also vgchange --poll n must not spawn any bg processes...
2015-05-09 02:59:18 +03:00
if test -e LOCAL_LVMPOLLD; then
aux lvmpolld_dump | tee lvmpolld_dump.txt
aux check_lvmpolld_init_rq_count 0 " $vg /pvmove0 "
aux check_lvmpolld_init_rq_count 0 " $vg1 /pvmove0 "
else
2017-07-10 11:40:09 +03:00
test " $( aux count_processes_with_tag) " -eq 0
2015-05-09 02:59:18 +03:00
fi
2015-04-03 11:41:33 +03:00
2015-04-28 16:31:47 +03:00
# ...thus finish polling
2017-07-03 21:55:11 +03:00
get lv_field $vg name -a | grep -E "^\[?pvmove0"
get lv_field $vg1 name -a | grep -E "^\[?pvmove0"
2015-04-03 11:41:33 +03:00
2015-04-28 16:31:47 +03:00
LVM_TEST_TAG = " kill_me_ $PREFIX " pvmove -b " $dev1 "
LVM_TEST_TAG = " kill_me_ $PREFIX " pvmove -b " $dev2 "
2015-04-03 11:41:33 +03:00
}
test_pvmove_resume lvchange_single
test_pvmove_resume lvchange_all
test_pvmove_resume vgchange_single
test_pvmove_resume vgchange_all
test_pvmove_resume pvmove_fg
test_pvmove_resume pvmove_fg_single
test_pvmove_resume pvmove_bg
test_pvmove_resume pvmove_bg_single
vgremove -ff $vg $vg1