2017-07-02 21:38:32 +02:00
#!/usr/bin/env bash
2010-04-14 13:51:58 +00:00
# Copyright (C) 2008 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 11:49:46 +01:00
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2010-04-14 13:51:58 +00:00
2016-02-22 16:13:42 -06:00
SKIP_WITH_LVMLOCKD = 1
2014-06-06 17:40:04 +02:00
. lib/inittest
2010-04-14 13:51:58 +00:00
2011-01-05 00:16:18 +00:00
aux prepare_vg 6
2015-04-08 22:44:16 +02:00
aux lvmconf 'allocation/maximise_cling = 0' \
'allocation/mirror_logs_require_separate_pvs = 1'
2010-04-14 13:51:58 +00:00
2011-01-11 17:05:08 +00:00
# 3-way, disk log
2010-04-14 13:51:58 +00:00
# multiple failures, full replace
2013-08-07 15:48:31 -05:00
lvcreate -aey --mirrorlog disk --type mirror -m 2 --ignoremonitoring --nosync -L 1 -n 3way $vg " $dev1 " " $dev2 " " $dev3 " " $dev4 " :0-1
2012-03-16 13:00:05 +00:00
aux disable_dev " $dev1 " " $dev2 "
2013-05-31 21:11:51 +02:00
lvconvert -y --repair $vg /3way 2>& 1 | tee 3way.out
2012-03-16 13:00:05 +00:00
lvs -a -o +devices $vg | not grep unknown
2010-04-14 13:51:58 +00:00
not grep "WARNING: Failed" 3way.out
vgreduce --removemissing $vg
check mirror $vg 3way
2012-03-16 13:00:05 +00:00
aux enable_dev " $dev1 " " $dev2 "
2013-05-31 21:11:51 +02:00
vgremove -ff $vg
2010-04-14 13:51:58 +00:00
2011-01-11 17:05:08 +00:00
# 3-way, disk log
2010-04-14 13:51:58 +00:00
# multiple failures, partial replace
2013-05-31 21:11:51 +02:00
vgcreate $vg " $dev1 " " $dev2 " " $dev3 " " $dev4 " " $dev5 "
2013-08-07 15:48:31 -05:00
lvcreate -aey --mirrorlog disk --type mirror -m 2 --ignoremonitoring --nosync -L 1 -n 3way $vg " $dev1 " " $dev2 " " $dev3 " " $dev4 "
2012-03-16 13:00:05 +00:00
aux disable_dev " $dev1 " " $dev2 "
2013-05-31 21:11:51 +02:00
lvconvert -y --repair $vg /3way 2>& 1 | tee 3way.out
2010-04-14 13:51:58 +00:00
grep "WARNING: Failed" 3way.out
2012-03-16 13:00:05 +00:00
lvs -a -o +devices $vg | not grep unknown
2010-04-14 13:51:58 +00:00
vgreduce --removemissing $vg
check mirror $vg 3way
2012-03-16 13:00:05 +00:00
aux enable_dev " $dev1 " " $dev2 "
2013-05-31 21:11:51 +02:00
vgremove -ff $vg
2010-04-14 13:51:58 +00:00
2013-05-31 21:11:51 +02:00
vgcreate $vg " $dev1 " " $dev2 " " $dev3 "
2013-08-07 15:48:31 -05:00
lvcreate -aey --mirrorlog disk --type mirror -m 1 --ignoremonitoring --nosync -l 1 -n 2way $vg " $dev1 " " $dev2 " " $dev3 "
2012-03-16 13:00:05 +00:00
aux disable_dev " $dev1 "
2013-05-31 21:11:51 +02:00
lvconvert -y --repair $vg /2way 2>& 1 | tee 2way.out
2010-04-14 13:51:58 +00:00
grep "WARNING: Failed" 2way.out
2012-03-16 13:00:05 +00:00
lvs -a -o +devices $vg | not grep unknown
2010-04-14 13:51:58 +00:00
vgreduce --removemissing $vg
check mirror $vg 2way
2012-03-16 13:00:05 +00:00
aux enable_dev " $dev1 " " $dev2 "
2013-05-31 21:11:51 +02:00
vgremove -ff $vg
2010-04-14 13:51:58 +00:00
2014-05-20 22:50:52 +02:00
# FIXME - exclusive activation for mirrors should work here
# conversion of inactive cluster logs is also unsupported
test -e LOCAL_CLVMD && exit 0
2010-04-14 13:51:58 +00:00
# Test repair of inactive mirror with log failure
2013-05-31 21:11:51 +02:00
# Replacement should fail, but convert should succeed (switch to corelog)
vgcreate $vg " $dev1 " " $dev2 " " $dev3 " " $dev4 "
2014-05-20 22:50:52 +02:00
lvcreate -aey --type mirror -m 2 --ignoremonitoring -l 2 -n mirror2 $vg " $dev1 " " $dev2 " " $dev3 " " $dev4 " :0
2010-04-14 13:51:58 +00:00
vgchange -a n $vg
2012-03-16 13:00:05 +00:00
pvremove -ff -y " $dev4 "
2013-05-31 21:11:51 +02:00
lvconvert -y --repair $vg /mirror2
2010-04-14 13:51:58 +00:00
check mirror $vg mirror2
2012-03-16 13:00:05 +00:00
vgs $vg
2013-05-31 21:11:51 +02:00
vgremove -ff $vg
2015-04-30 13:23:56 +02:00
if aux kernel_at_least 3 0 0; then
2013-05-26 18:53:29 +02:00
# 2-way, mirrored log
# Double log failure, full replace
vgcreate $vg " $dev1 " " $dev2 " " $dev3 " " $dev4 " " $dev5 " " $dev6 "
2013-08-07 15:48:31 -05:00
lvcreate -aey --mirrorlog mirrored --type mirror -m 1 --ignoremonitoring --nosync -L 1 -n 2way $vg \
2013-05-26 18:53:29 +02:00
" $dev1 " " $dev2 " " $dev3 " :0 " $dev4 " :0
aux disable_dev " $dev3 " " $dev4 "
lvconvert -y --repair $vg /2way 2>& 1 | tee 2way.out
lvs -a -o +devices $vg | not grep unknown
not grep "WARNING: Failed" 2way.out
vgreduce --removemissing $vg
check mirror $vg 2way
aux enable_dev " $dev3 " " $dev4 "
vgremove -ff $vg
fi
2013-05-31 21:11:51 +02:00
# 3-way, mirrored log
# Single log failure, replace
vgcreate $vg " $dev1 " " $dev2 " " $dev3 " " $dev4 " " $dev5 " " $dev6 "
2013-08-07 15:48:31 -05:00
lvcreate -aey --mirrorlog mirrored --type mirror -m 2 --ignoremonitoring --nosync -L 1 -n 3way $vg \
2013-05-31 21:11:51 +02:00
" $dev1 " " $dev2 " " $dev3 " " $dev4 " :0 " $dev5 " :0
aux disable_dev " $dev4 "
lvconvert -y --repair $vg /3way 2>& 1 | tee 3way.out
lvs -a -o +devices $vg | not grep unknown
not grep "WARNING: Failed" 3way.out
vgreduce --removemissing $vg
check mirror $vg 3way
aux enable_dev " $dev4 "
vgremove -ff $vg