2013-08-30 16:53:57 +04:00
#!/bin/sh
# Copyright (C) 2013 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,
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# Check pvmove behavior when it's progress and machine is rebooted
. lib/test
aux prepare_pvs 3 60
vgcreate -s 128k $vg " $dev1 " " $dev2 " " $dev3 "
# Create multisegment LV
lvcreate -an -Zn -l5 -n $lv1 $vg " $dev1 "
lvextend -l+10 $vg /$lv1 " $dev2 "
lvextend -l+5 $vg /$lv1 " $dev1 "
lvextend -l+10 $vg /$lv1 " $dev2 "
# Slowdown writes
aux delay_dev " $dev3 " 0 100
lvs -o+devices $vg
pvmove -i0 -n $vg /$lv1 " $dev1 " " $dev3 " &
PVMOVE = $!
# Let's wait a bit till pvmove starts and kill it
sleep 1
kill -9 $PVMOVE
2013-12-04 20:05:44 +04:00
wait
2013-08-30 16:53:57 +04:00
# Simulate reboot - forcibly remove related devices
dmsetup remove $vg -$lv1
dmsetup remove $vg -pvmove0
2014-04-11 00:12:37 +04:00
# Check we really have pvmove volume
check lv_attr_bit type $vg /pvmove0 "p"
2013-12-04 20:05:44 +04:00
if test -e LOCAL_CLVMD ; then
# giveup all clvmd locks (faster then restarting clvmd)
# no deactivation happen, nodes are already removed
2014-04-11 00:12:37 +04:00
#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
2013-12-04 20:05:44 +04:00
# Restart clvmd
2014-04-11 00:12:37 +04:00
kill $( cat LOCAL_CLVMD)
for i in $( seq 1 100) ; do
test $i -eq 100 && die "Shutdown of clvmd is too slow."
2014-04-14 16:55:14 +04:00
test -e " $CLVMD_PIDFILE " || break
2014-04-11 00:12:37 +04:00
sleep .1
done # wait for the pid removal
aux prepare_clvmd
2013-12-04 20:05:44 +04:00
fi
if test -e LOCAL_LVMETAD ; then
# Restart lvmetad
kill $( cat LOCAL_LVMETAD)
aux prepare_lvmetad
fi
2013-08-30 16:53:57 +04:00
# Only PVs should be left in table...
dmsetup table
# Restart pvmove
2013-12-04 20:05:44 +04:00
# use exclusive activation to have usable pvmove without cmirrord
vgchange -aey $vg
2014-04-11 00:12:37 +04:00
#sleep 2
2013-12-04 20:05:44 +04:00
#pvmove
2013-08-30 16:53:57 +04:00
pvmove --abort
# Restore delayed device back
aux delay_dev " $dev3 "
lvs -a -o+devices $vg
2014-02-27 02:25:30 +04:00
vgremove -ff $vg