2017-07-02 22:38:32 +03:00
#!/usr/bin/env bash
2009-10-06 00:53:41 +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
2009-10-06 00:53:41 +04:00
#
# Exercise various vgextend commands
#
2018-05-24 17:49:48 +03:00
2015-10-27 17:10:06 +03:00
SKIP_WITH_LVMPOLLD = 1
2009-10-06 00:53:41 +04:00
2015-10-27 17:10:06 +03:00
. lib/inittest
2015-05-09 02:59:18 +03:00
2009-10-06 00:53:41 +04:00
aux prepare_devs 5
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
2009-10-06 00:53:41 +04:00
do
# Explicit pvcreate
2012-03-16 17:00:05 +04:00
pvcreate -M$mdatype " $dev1 " " $dev2 " " $dev3 " " $dev4 " " $dev5 "
2018-05-24 17:49:48 +03:00
vgcreate $SHARED -M$mdatype $vg1 " $dev1 " " $dev2 "
2012-03-16 17:00:05 +04:00
vgextend $vg1 " $dev3 " " $dev4 " " $dev5 "
2009-10-06 00:53:41 +04:00
vgremove -ff $vg1
# Implicit pvcreate
2012-03-16 17:00:05 +04:00
pvremove " $dev1 " " $dev2 " " $dev3 " " $dev4 " " $dev5 "
2018-05-24 17:49:48 +03:00
vgcreate $SHARED -M$mdatype $vg1 " $dev1 " " $dev2 "
2012-03-16 17:00:05 +04:00
vgextend -M$mdatype $vg1 " $dev3 " " $dev4 " " $dev5 "
2009-10-06 00:53:41 +04:00
vgremove -ff $vg1
2012-03-16 17:00:05 +04:00
pvremove " $dev1 " " $dev2 " " $dev3 " " $dev4 " " $dev5 "
2009-10-06 00:53:41 +04:00
done
2018-05-24 17:49:48 +03:00
# Implicit pvcreate tests, test pvcreate options on vgcreate $SHARED
2009-10-06 00:53:41 +04:00
# --force, --yes, --metadata{size|copies|type}, --zero
# --dataalignment[offset]
2018-05-24 17:49:48 +03:00
vgcreate $SHARED $vg " $dev2 "
2012-03-16 17:00:05 +04:00
vgextend --force --yes --zero y $vg " $dev1 "
vgreduce $vg " $dev1 "
pvremove -f " $dev1 "
2009-10-06 00:53:41 +04:00
for i in 0 1 2 3
do
2018-05-24 17:49:48 +03:00
# vgcreate $SHARED (lvm2) succeeds writing LVM label at sector $i
2012-03-16 17:00:05 +04:00
vgextend --labelsector $i $vg " $dev1 "
dd if = " $dev1 " bs = 512 skip = $i count = 1 2>/dev/null | strings | grep LABELONE >/dev/null
vgreduce $vg " $dev1 "
pvremove -f " $dev1 "
2009-10-06 00:53:41 +04:00
done
2009-10-06 00:55:56 +04:00
# pvmetadatacopies
2009-10-06 00:53:41 +04:00
for i in 0 1 2
do
2012-03-16 17:00:05 +04:00
vgextend --pvmetadatacopies $i $vg " $dev1 "
check pv_field " $dev1 " pv_mda_count $i
vgreduce $vg " $dev1 "
pvremove -f " $dev1 "
2009-10-06 00:53:41 +04:00
done
# metadatasize, dataalignment, dataalignmentoffset
#COMM 'pvcreate sets data offset next to mda area'
2012-03-16 17:00:05 +04:00
vgextend --metadatasize 100k --dataalignment 100k $vg " $dev1 "
check pv_field " $dev1 " pe_start 200.00k
vgreduce $vg " $dev1 "
pvremove -f " $dev1 "
2009-10-06 00:53:41 +04:00
2010-08-12 08:11:48 +04:00
# data area is aligned to 1M by default,
2009-10-06 00:53:41 +04:00
# data area start is shifted by the specified alignment_offset
2012-03-16 17:00:05 +04:00
pv_align = 1052160B # 1048576 + (7*512)
vgextend --metadatasize 128k --dataalignmentoffset 7s $vg " $dev1 "
check pv_field " $dev1 " pe_start $pv_align --units b
2009-10-06 00:53:41 +04:00
vgremove -f $vg
2012-03-16 17:00:05 +04:00
pvremove -f " $dev1 "
2009-10-06 00:53:41 +04:00
2009-10-31 19:43:07 +03:00
# vgextend fails if pv belongs to existing vg
2018-05-24 17:49:48 +03:00
vgcreate $SHARED $vg1 " $dev1 " " $dev3 "
vgcreate $SHARED $vg2 " $dev2 "
2012-03-16 17:00:05 +04:00
not vgextend $vg2 " $dev3 "
2009-10-31 19:43:07 +03:00
vgremove -f $vg1
vgremove -f $vg2
2012-03-16 17:00:05 +04:00
pvremove -f " $dev1 " " $dev2 " " $dev3 "
2009-10-31 19:43:07 +03:00
#vgextend fails if vg is not resizeable
2018-05-24 17:49:48 +03:00
vgcreate $SHARED $vg1 " $dev1 " " $dev2 "
2009-10-31 19:43:07 +03:00
vgchange --resizeable n $vg1
2012-03-16 17:00:05 +04:00
not vgextend $vg1 " $dev3 "
2009-10-31 19:43:07 +03:00
vgremove -f $vg1
2012-03-16 17:00:05 +04:00
pvremove -f " $dev1 " " $dev2 "
2009-10-31 19:43:07 +03:00
# all PVs exist in the VG after extended
2012-03-16 17:00:05 +04:00
pvcreate " $dev1 "
2018-05-24 17:49:48 +03:00
vgcreate $SHARED $vg1 " $dev2 "
2012-03-16 17:00:05 +04:00
vgextend $vg1 " $dev1 " " $dev3 "
check pv_field " $dev1 " vg_name $vg1
check pv_field " $dev2 " vg_name $vg1
check pv_field " $dev3 " vg_name $vg1
2009-10-31 19:43:07 +03:00
vgremove -f $vg1
2012-03-16 17:00:05 +04:00
pvremove -f " $dev1 " " $dev2 " " $dev3 "
2010-06-30 17:04:59 +04:00
echo test vgextend --metadataignore
for mdacp in 1 2; do
for ignore in y n; do
echo vgextend --metadataignore has proper mda_count and mda_used_count
2018-05-24 17:49:48 +03:00
vgcreate $SHARED $vg " $dev3 "
2012-03-16 17:00:05 +04:00
vgextend --metadataignore $ignore --pvmetadatacopies $mdacp $vg " $dev1 " " $dev2 "
check pv_field " $dev1 " pv_mda_count $mdacp
check pv_field " $dev2 " pv_mda_count $mdacp
2010-06-30 17:04:59 +04:00
if [ $ignore = y ] ; then
2012-03-16 17:00:05 +04:00
check pv_field " $dev1 " pv_mda_used_count 0
check pv_field " $dev2 " pv_mda_used_count 0
2010-06-30 17:04:59 +04:00
else
2012-03-16 17:00:05 +04:00
check pv_field " $dev1 " pv_mda_used_count $mdacp
check pv_field " $dev2 " pv_mda_used_count $mdacp
2010-06-30 17:04:59 +04:00
fi
echo vg has proper vg_mda_count and vg_mda_used_count
2017-07-06 20:27:04 +03:00
check vg_field $vg vg_mda_count $(( mdacp * 2 + 1 ))
2010-06-30 17:04:59 +04:00
if [ $ignore = y ] ; then
2011-01-05 03:16:18 +03:00
check vg_field $vg vg_mda_used_count 1
2010-06-30 17:04:59 +04:00
else
2017-07-06 20:27:04 +03:00
check vg_field $vg vg_mda_used_count $(( mdacp * 2 + 1 ))
2010-06-30 17:04:59 +04:00
fi
2011-01-05 03:16:18 +03:00
check vg_field $vg vg_mda_copies unmanaged
2010-06-30 17:04:59 +04:00
vgremove $vg
2012-03-16 17:00:05 +04:00
pvremove -ff " $dev1 " " $dev2 " " $dev3 "
2010-06-30 17:04:59 +04:00
done
done