2017-07-02 22:38:32 +03:00
#!/usr/bin/env bash
2008-08-12 14:04:31 +04: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 13:49:46 +03:00
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2008-08-12 14:04:31 +04:00
2018-05-30 20:55:49 +03:00
2015-10-27 17:10:06 +03:00
SKIP_WITH_LVMPOLLD = 1
2008-09-30 21:17:04 +04:00
2015-10-27 17:10:06 +03:00
. lib/inittest
2015-05-09 02:59:18 +03:00
2008-09-30 21:17:04 +04:00
aux prepare_devs 4
2017-07-06 20:41:25 +03:00
get_devs
2008-08-12 14:04:31 +04:00
2016-03-03 01:49:32 +03:00
if test -n " $LVM_TEST_LVM1 " ; then
mdatypes = '1 2'
else
mdatypes = '2'
fi
for mdatype in $mdatypes
2008-08-12 14:04:31 +04:00
do
2008-09-30 21:17:04 +04:00
# setup PVs
2012-03-16 17:00:05 +04:00
pvcreate -M$mdatype " $dev1 " " $dev2 "
2008-09-30 21:17:04 +04:00
# (lvm$mdatype) vgreduce removes only the specified pv from vg (bz427382)" '
2018-05-30 20:55:49 +03:00
vgcreate $SHARED -M$mdatype $vg1 " $dev1 " " $dev2 "
2012-03-16 17:00:05 +04:00
vgreduce $vg1 " $dev1 "
check pv_field " $dev2 " vg_name $vg1
2008-09-30 21:17:04 +04:00
vgremove -f $vg1
# (lvm$mdatype) vgreduce rejects removing the last pv (--all)
2018-05-30 20:55:49 +03:00
vgcreate $SHARED -M$mdatype $vg1 " $dev1 " " $dev2 "
2008-09-30 21:17:04 +04:00
not vgreduce --all $vg1
vgremove -f $vg1
# (lvm$mdatype) vgreduce rejects removing the last pv
2018-05-30 20:55:49 +03:00
vgcreate $SHARED -M$mdatype $vg1 " $dev1 " " $dev2 "
2012-03-16 17:00:05 +04:00
not vgreduce $vg1 " $dev1 " " $dev2 "
2008-09-30 21:17:04 +04:00
vgremove -f $vg1
2012-03-16 17:00:05 +04:00
pvremove -ff " $dev1 " " $dev2 "
2008-08-12 14:04:31 +04:00
done
2008-09-30 21:17:04 +04:00
mdatype = 2 # we only expect the following to work for lvm2 metadata
# (lvm$mdatype) setup PVs (--metadatacopies 0)
2012-03-16 17:00:05 +04:00
pvcreate -M$mdatype " $dev1 " " $dev2 "
pvcreate --metadatacopies 0 -M$mdatype " $dev3 " " $dev4 "
2008-09-30 21:17:04 +04:00
2008-11-10 15:43:35 +03:00
# (lvm$mdatype) vgreduce rejects removing pv with the last mda copy (bz247448)
2018-05-30 20:55:49 +03:00
vgcreate $SHARED -M$mdatype $vg1 " $dev1 " " $dev3 "
2012-03-16 17:00:05 +04:00
not vgreduce $vg1 " $dev1 "
2008-09-30 21:17:04 +04:00
vgremove -f $vg1
2008-11-10 15:43:35 +03:00
#COMM "(lvm$mdatype) vgreduce --removemissing --force repares to linear (bz221921)"
2008-09-30 21:17:04 +04:00
# (lvm$mdatype) setup: create mirror & damage one pv
2018-05-30 20:55:49 +03:00
vgcreate $SHARED -M$mdatype $vg1 " $dev1 " " $dev2 " " $dev3 "
2013-08-08 00:48:31 +04:00
lvcreate -aey -n $lv1 --type mirror -m1 -l 4 $vg1
2012-03-16 17:00:05 +04:00
lvcreate -n $lv2 -l 4 $vg1 " $dev2 "
lvcreate -n $lv3 -l 4 $vg1 " $dev3 "
2008-09-30 21:17:04 +04:00
vgchange -an $vg1
2012-03-16 17:00:05 +04:00
aux disable_dev " $dev1 "
2008-09-30 21:17:04 +04:00
# (lvm$mdatype) vgreduce --removemissing --force repares to linear
vgreduce --removemissing --force $vg1
2011-01-05 03:16:18 +03:00
check lv_field $vg1 /$lv1 segtype linear
check pvlv_counts $vg1 2 3 0
2008-11-10 15:43:35 +03:00
# cleanup
2012-03-16 17:00:05 +04:00
aux enable_dev " $dev1 "
2011-07-11 16:13:07 +04:00
pvscan
2012-03-16 17:00:05 +04:00
vgremove -f $vg1
2011-07-11 16:13:07 +04:00
not vgs $vg1 # just double-check it's really gone
2008-09-30 21:17:04 +04:00
2008-11-10 15:43:35 +03:00
#COMM "vgreduce rejects --removemissing --mirrorsonly --force when nonmirror lv lost too"
2008-09-30 21:17:04 +04:00
# (lvm$mdatype) setup: create mirror + linear lvs
2018-05-30 20:55:49 +03:00
vgcreate $SHARED -M$mdatype " $vg1 " " ${ DEVICES [@] } "
2008-09-30 21:17:04 +04:00
lvcreate -n $lv2 -l 4 $vg1
2013-08-08 00:48:31 +04:00
lvcreate -aey --type mirror -m1 -n $lv1 -l 4 $vg1 " $dev1 " " $dev2 " " $dev3 "
2012-03-16 17:00:05 +04:00
lvcreate -n $lv3 -l 4 $vg1 " $dev3 "
2017-07-06 20:41:25 +03:00
pvs --segments -o +lv_name " ${ DEVICES [@] } " # for record only
2008-09-30 21:17:04 +04:00
# (lvm$mdatype) setup: damage one pv
2012-03-16 17:00:05 +04:00
vgchange -an $vg1
aux disable_dev " $dev1 "
#pvcreate -ff -y "$dev1"
2008-09-30 21:17:04 +04:00
# vgreduce rejects --removemissing --mirrorsonly --force when nonmirror lv lost too
2012-03-16 17:00:05 +04:00
#not vgreduce -c n --removemissing --mirrorsonly --force $vg1
# CHECKME - command above was rejected becuase of '-c n'
vgreduce --removemissing --mirrorsonly --force $vg1
2008-08-12 14:04:31 +04:00
2012-03-16 17:00:05 +04:00
aux enable_dev " $dev1 "
2008-11-10 15:43:35 +03:00
2017-07-06 20:41:25 +03:00
pvs -P " ${ DEVICES [@] } " # for record
2012-03-16 17:00:05 +04:00
lvs -P $vg1 # for record
vgs -P $vg1 # for record
2014-02-27 02:25:30 +04:00
vgremove -ff $vg1