2017-07-02 22:38:32 +03:00
#!/usr/bin/env bash
2012-03-16 17:00:05 +04:00
# Copyright (C) 2008-2012 Red Hat, Inc. All rights reserved.
2008-01-11 10:02:35 +03:00
#
# 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-01-11 10:02:35 +03:00
test_description = 'Exercise some vgcreate diagnostics'
2018-05-25 22:28:53 +03:00
2015-10-27 17:10:06 +03:00
SKIP_WITH_LVMPOLLD = 1
2008-01-11 10:02:35 +03:00
2014-06-06 19:40:04 +04:00
. lib/inittest
2008-10-06 20:47:07 +04:00
aux prepare_devs 3
2012-03-16 17:00:05 +04:00
pvcreate " $dev1 " " $dev2 "
pvcreate --metadatacopies 0 " $dev3 "
2008-10-06 20:47:07 +04:00
2010-05-12 14:08:35 +04:00
vg = ${ PREFIX } vg
2018-05-25 22:28:53 +03:00
#COMM 'vgcreate $SHARED accepts 8.00m physicalextentsize for VG'
vgcreate $SHARED $vg --physicalextentsize 8.00m " $dev1 " " $dev2 "
2011-01-05 03:16:18 +03:00
check vg_field $vg vg_extent_size 8.00m
2008-10-06 20:47:07 +04:00
vgremove $vg
2009-07-14 23:35:35 +04:00
# try vgck and to remove it again - should fail (but not segfault)
not vgremove $vg
not vgck $vg
2008-10-06 20:47:07 +04:00
2018-05-25 22:28:53 +03:00
#COMM 'vgcreate $SHARED accepts smaller (128) maxlogicalvolumes for VG'
vgcreate $SHARED $vg --maxlogicalvolumes 128 " $dev1 " " $dev2 "
2011-01-05 03:16:18 +03:00
check vg_field $vg max_lv 128
2008-10-06 20:47:07 +04:00
vgremove $vg
2018-05-25 22:28:53 +03:00
#COMM 'vgcreate $SHARED accepts smaller (128) maxphysicalvolumes for VG'
vgcreate $SHARED $vg --maxphysicalvolumes 128 " $dev1 " " $dev2 "
2011-01-05 03:16:18 +03:00
check vg_field $vg max_pv 128
2008-10-06 20:47:07 +04:00
vgremove $vg
2018-05-25 22:28:53 +03:00
#COMM 'vgcreate $SHARED rejects a zero physical extent size'
not vgcreate $SHARED --physicalextentsize 0 $vg " $dev1 " " $dev2 " 2>err
2012-03-16 17:00:05 +04:00
grep "Physical extent size may not be zero" err
2008-10-06 20:47:07 +04:00
2018-05-25 22:28:53 +03:00
#COMM 'vgcreate $SHARED rejects "inherit" allocation policy'
not vgcreate $SHARED --alloc inherit $vg " $dev1 " " $dev2 " 2>err
2012-03-16 17:00:05 +04:00
grep "Volume Group allocation policy cannot inherit from anything" err
2008-10-06 20:47:07 +04:00
2018-05-25 22:28:53 +03:00
#COMM 'vgcreate $SHARED rejects vgname "."'
2008-10-06 20:47:07 +04:00
vginvalid = .;
2018-05-25 22:28:53 +03:00
not vgcreate $SHARED $vginvalid " $dev1 " " $dev2 " 2>err
2012-03-16 17:00:05 +04:00
grep " New volume group name \" $vginvalid \" is invalid " err
2008-10-06 20:47:07 +04:00
2018-05-25 22:28:53 +03:00
#COMM 'vgcreate $SHARED rejects vgname greater than 128 characters'
2008-10-06 20:47:07 +04:00
vginvalid = thisnameisridiculouslylongtotestvalidationcodecheckingmaximumsizethisiswhathappenswhenprogrammersgetboredandorarenotcreativedonttrythisathome
2018-05-25 22:28:53 +03:00
not vgcreate $SHARED $vginvalid " $dev1 " " $dev2 " 2>err
2012-03-16 17:00:05 +04:00
grep " New volume group name \" $vginvalid \" is invalid " err
2008-10-06 20:47:07 +04:00
2018-05-25 22:28:53 +03:00
#COMM 'vgcreate $SHARED rejects already existing vgname "/tmp/$vg"'
2008-10-06 20:47:07 +04:00
#touch /tmp/$vg
2018-05-25 22:28:53 +03:00
#not vgcreate $SHARED $vg "$dev1" "$dev2" 2>err
2008-10-06 20:47:07 +04:00
#grep "New volume group name \"$vg\" is invalid\$" err
2018-05-25 22:28:53 +03:00
#COMM "vgcreate $SHARED rejects repeated invocation (run 2 times) (bz178216)"
vgcreate $SHARED $vg " $dev1 " " $dev2 "
not vgcreate $SHARED $vg " $dev1 " " $dev2 "
2008-10-06 20:47:07 +04:00
vgremove -ff $vg
2018-05-25 22:28:53 +03:00
#COMM "vgcreate $SHARED fails when the only pv has --metadatacopies 0"
not vgcreate $SHARED $vg " $dev3 "
2009-05-08 09:15:52 +04:00
# Test default (4MB) vg_extent_size as well as limits of extent_size
2018-05-25 22:28:53 +03:00
not vgcreate $SHARED --physicalextentsize 0k $vg " $dev1 " " $dev2 "
vgcreate $SHARED --physicalextentsize 4k $vg " $dev1 " " $dev2 "
2018-05-12 23:52:41 +03:00
check vg_field $vg vg_extent_size 4.00k
2009-05-08 09:15:52 +04:00
vgremove -ff $vg
2018-05-25 22:28:53 +03:00
not vgcreate $SHARED --physicalextentsize 7K $vg " $dev1 " " $dev2 "
not vgcreate $SHARED --physicalextentsize 1024t $vg " $dev1 " " $dev2 "
#not vgcreate $SHARED --physicalextentsize 1T $vg "$dev1" "$dev2"
# FIXME: vgcreate $SHARED allows physicalextentsize larger than pv size!
2009-07-09 12:50:55 +04:00
# Test default max_lv, max_pv, extent_size, alloc_policy, clustered
2018-05-25 22:28:53 +03:00
vgcreate $SHARED $vg " $dev1 " " $dev2 "
2011-01-05 03:16:18 +03:00
check vg_field $vg vg_extent_size 4.00m
check vg_field $vg max_lv 0
check vg_field $vg max_pv 0
2013-05-31 23:11:51 +04:00
ATTRS = "wz--n-"
test -e LOCAL_CLVMD && ATTRS = "wz--nc"
2018-05-25 22:28:53 +03:00
if test -n " $LVM_TEST_LVMLOCKD " ; then
ATTRS = "wz--ns"
fi
2013-05-31 23:11:51 +04:00
check vg_field $vg vg_attr $ATTRS
2009-07-09 12:50:55 +04:00
vgremove -ff $vg
2009-10-06 00:04:40 +04:00
2018-05-25 22:28:53 +03:00
# Implicit pvcreate tests, test pvcreate options on vgcreate $SHARED
2009-10-06 00:04:40 +04:00
# --force, --yes, --metadata{size|copies|type}, --zero
# --dataalignment[offset]
2012-03-16 17:00:05 +04:00
pvremove " $dev1 " " $dev2 "
2018-05-25 22:28:53 +03:00
vgcreate $SHARED --force --yes --zero y $vg " $dev1 " " $dev2 "
2009-10-06 00:04:40 +04:00
vgremove -f $vg
2012-03-16 17:00:05 +04:00
pvremove -f " $dev1 "
2009-10-06 00:04:40 +04:00
for i in 0 1 2 3
do
2018-05-25 22:28:53 +03:00
# vgcreate $SHARED (lvm2) succeeds writing LVM label at sector $i
vgcreate $SHARED --labelsector $i $vg " $dev1 "
2012-03-16 17:00:05 +04:00
dd if = " $dev1 " bs = 512 skip = $i count = 1 2>/dev/null | strings | grep LABELONE >/dev/null
2009-10-06 00:04:40 +04:00
vgremove -f $vg
2012-03-16 17:00:05 +04:00
pvremove -f " $dev1 "
2009-10-06 00:04:40 +04:00
done
2009-10-06 00:55:56 +04:00
# pvmetadatacopies
2009-10-06 00:04:40 +04:00
for i in 1 2
do
2018-05-25 22:28:53 +03:00
vgcreate $SHARED --pvmetadatacopies $i $vg " $dev1 "
2012-03-16 17:00:05 +04:00
check pv_field " $dev1 " pv_mda_count $i
2009-10-06 00:04:40 +04:00
vgremove -f $vg
2012-03-16 17:00:05 +04:00
pvremove -f " $dev1 "
2009-10-06 00:04:40 +04:00
done
2018-05-25 22:28:53 +03:00
not vgcreate $SHARED --pvmetadatacopies 0 $vg " $dev1 "
2012-03-16 17:00:05 +04:00
pvcreate --metadatacopies 1 " $dev2 "
2018-05-25 22:28:53 +03:00
vgcreate $SHARED --pvmetadatacopies 0 $vg " $dev1 " " $dev2 "
2012-03-16 17:00:05 +04:00
check pv_field " $dev1 " pv_mda_count 0
check pv_field " $dev2 " pv_mda_count 1
2009-10-06 00:04:40 +04:00
vgremove -f $vg
2012-03-16 17:00:05 +04:00
pvremove -f " $dev1 "
2009-10-06 00:04:40 +04:00
# metadatasize, dataalignment, dataalignmentoffset
#COMM 'pvcreate sets data offset next to mda area'
2018-05-25 22:28:53 +03:00
vgcreate $SHARED --metadatasize 100k --dataalignment 100k $vg " $dev1 "
2012-03-16 17:00:05 +04:00
check pv_field " $dev1 " pe_start 200.00k
2009-10-06 00:04:40 +04:00
vgremove -f $vg
2012-03-16 17:00:05 +04:00
pvremove -f " $dev1 "
2009-10-06 00:04:40 +04:00
2010-08-12 08:11:48 +04:00
# data area is aligned to 1M by default,
2009-10-06 00:04:40 +04:00
# data area start is shifted by the specified alignment_offset
2012-03-16 17:00:05 +04:00
pv_align = 1052160 # 1048576 + (7*512)
2018-05-25 22:28:53 +03:00
vgcreate $SHARED --metadatasize 128k --dataalignmentoffset 7s $vg " $dev1 "
2012-03-16 17:00:05 +04:00
check pv_field " $dev1 " pe_start ${ pv_align } B --units b
2009-10-06 00:04:40 +04:00
vgremove -f $vg
2012-03-16 17:00:05 +04:00
pvremove -f " $dev1 "
2009-10-06 00:04:40 +04:00
2016-03-03 01:49:32 +03:00
if test -n " $LVM_TEST_LVM1 " ; then
mdatypes = '1 2'
else
mdatypes = '2'
fi
2009-10-06 00:04:40 +04:00
# metadatatype
2016-03-03 01:49:32 +03:00
for i in $mdatypes
2009-10-06 00:04:40 +04:00
do
2018-05-25 22:28:53 +03:00
vgcreate $SHARED -M $i $vg " $dev1 "
2011-01-05 03:16:18 +03:00
check vg_field $vg vg_fmt lvm$i
2009-10-06 00:04:40 +04:00
vgremove -f $vg
2012-03-16 17:00:05 +04:00
pvremove -f " $dev1 "
2009-10-06 00:04:40 +04:00
done
2009-10-31 19:43:07 +03:00
2018-05-25 22:28:53 +03:00
# vgcreate $SHARED fails if pv belongs to existing vg
vgcreate $SHARED $vg1 " $dev1 " " $dev2 "
not vgcreate $SHARED $vg2 " $dev2 "
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 created
2012-03-16 17:00:05 +04:00
pvcreate " $dev1 "
2018-05-25 22:28:53 +03:00
vgcreate $SHARED $vg1 " $dev1 " " $dev2 " " $dev3 "
2012-03-16 17:00:05 +04:00
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