2017-07-02 22:38:32 +03:00
#!/usr/bin/env bash
2008-11-11 18:29:24 +03: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-11-11 18:29:24 +03:00
test_description = 'Exercise some vgchange diagnostics'
2016-02-23 01:13:42 +03:00
SKIP_WITH_LVMLOCKD = 1
2015-10-27 17:10:06 +03:00
SKIP_WITH_LVMPOLLD = 1
2008-11-11 18:29:24 +03:00
2014-06-06 19:40:04 +04:00
. lib/inittest
2008-11-11 18:29:24 +03:00
2014-05-22 14:00:59 +04:00
aux prepare_pvs 4
2012-03-16 17:00:05 +04:00
pvcreate --metadatacopies 0 " $dev1 "
2014-05-22 14:00:59 +04:00
vgcreate -s 4M $vg " $dev1 " " $dev2 " " $dev3 "
# cannot change anything in exported vg
vgexport $vg
fail vgchange -ay $vg
fail vgchange -p 8 $vg
fail vgchange -x n $vg
fail vgchange --addtag tag $vg
fail vgchange --deltag tag $vg
fail vgchange -s 4k $vg
fail vgchange --uuid $vg
fail vgchange --alloc anywhere $vg
fail vgchange -c y $vg
vgimport $vg
# unsupported combinations of options...
invalid vgchange --ignorelockingfailure --uuid $vg
invalid vgchange --sysinit --alloc normal $vg
invalid vgchange --sysinit --poll y $vg
invalid vgchange -an --poll y $vg
invalid vgchange -an --monitor y $vg
invalid vgchange -ay --refresh $vg
2008-11-11 18:29:24 +03:00
vgdisplay $vg
# vgchange -p MaxPhysicalVolumes (bz202232)
2014-05-22 14:00:59 +04:00
check vg_field $vg max_pv 0
2008-11-11 18:29:24 +03:00
vgchange -p 128 $vg
2014-05-22 14:00:59 +04:00
check vg_field $vg max_pv 128
2008-11-11 18:29:24 +03:00
2011-01-05 03:16:18 +03:00
pv_count = $( get vg_field $vg pv_count)
2008-11-11 18:29:24 +03:00
not vgchange -p 2 $vg 2>err
grep " MaxPhysicalVolumes is less than the current number $pv_count of PVs for " err
2014-05-22 14:00:59 +04:00
check vg_field $vg max_pv 128
2008-11-11 18:29:24 +03:00
2017-01-03 15:04:51 +03:00
# try some numbers around MAX limit (uint32)
vgchange -p 4294967295 $vg
invalid vgchange -p 4294967296 $vg
invalid vgchange -p 18446744073709551615 $vg
invalid vgchange -p 18446744073709551616 $vg
check vg_field $vg max_pv 4294967295
2008-11-11 18:29:24 +03:00
# vgchange -l MaxLogicalVolumes
2014-05-22 14:00:59 +04:00
check vg_field $vg max_lv 0
invalid vgchange -l -128 $vg
2017-01-06 23:24:16 +03:00
vgchange -l 4294967295 $vg
invalid vgchange -l 4294967296 $vg
invalid vgchange -l 18446744073709551615 $vg
invalid vgchange -l 18446744073709551616 $vg
check vg_field $vg max_lv 4294967295
2008-11-11 18:29:24 +03:00
vgchange -l 128 $vg
2014-05-22 14:00:59 +04:00
check vg_field $vg max_lv 128
2008-11-11 18:29:24 +03:00
2014-05-22 14:00:59 +04:00
# vgchange -s
2012-03-16 17:00:05 +04:00
lvcreate -l4 -n $lv1 $vg
lvcreate -l4 -n $lv2 $vg
2014-05-22 14:00:59 +04:00
SIZELV2 = $( get lv_field $vg /$lv2 size)
check lv_field $vg /$lv2 seg_size_pe "4"
vgchange -s 4K $vg
check vg_field $vg vg_extent_size "4.00k"
check lv_field $vg /$lv2 size " $SIZELV2 "
check lv_field $vg /$lv2 seg_size_pe "4096"
2008-11-11 18:29:24 +03:00
2011-01-05 03:16:18 +03:00
lv_count = $( get vg_field $vg lv_count)
2008-11-11 18:29:24 +03:00
not vgchange -l 1 $vg 2>err
grep " MaxLogicalVolume is less than the current number $lv_count of LVs for " err
2014-05-22 14:00:59 +04:00
check vg_field $vg max_lv 128
# check non-resizebility
fail vgchange -x y $vg
check vg_attr_bit resizeable $vg "z"
vgchange -x n $vg
check vg_attr_bit resizeable $vg "-"
fail vgchange -x n $vg
fail vgextend $vg " $dev4 "
vgremove -ff $vg
# set cluster bit
vgcreate -cn $vg " $dev1 " " $dev2 " " $dev3 "
# check prompt to change cluster bit without giving explicit vg name
2015-05-14 11:20:24 +03:00
fail vgchange -cy 2>& 1 | tee out
2014-05-22 14:00:59 +04:00
grep "y/n" out
check vg_attr_bit cluster $vg "-"
2014-09-17 16:27:46 +04:00
lvcreate -l1 -n $lv1 $vg
2014-09-16 13:41:28 +04:00
2014-05-22 14:00:59 +04:00
# check on cluster
# either skipped as clustered (non-cluster), or already clustered (on cluster)
if test -e LOCAL_CLVMD ; then
2014-09-17 16:27:46 +04:00
# can switch with active LV
2014-06-10 15:13:51 +04:00
vgchange -cy $vg
fail vgchange -cy $vg
2014-09-17 16:27:46 +04:00
# check volume is active locally exclusively
check lv_field $vg /$lv1 lv_active "local exclusive"
2014-05-22 14:00:59 +04:00
check vg_attr_bit cluster $vg "c"
2014-09-17 16:27:46 +04:00
# check we do not support conversion of just locally active LVs
lvchange -an $vg
2014-09-16 13:41:28 +04:00
lvchange -ay $vg
not vgchange -cn $vg
lvchange -an $vg
2014-09-17 16:27:46 +04:00
lvchange -aey $vg
2014-05-22 14:00:59 +04:00
vgchange -cn $vg
else
2014-06-10 15:13:51 +04:00
# no clvmd is running
fail vgchange -cy $vg
2014-09-16 13:41:28 +04:00
# can't switch with active LV
2014-06-10 15:13:51 +04:00
vgchange --yes -cy $vg
fail vgchange --yes -cy $vg
2015-05-14 11:20:24 +03:00
fail vgs $vg 2>& 1 | tee out
2014-05-22 14:00:59 +04:00
grep "Skipping clustered volume group" out
2015-05-14 11:20:24 +03:00
vgs --ignoreskippedcluster $vg 2>& 1 | tee out
2014-05-22 14:00:59 +04:00
not grep "Skipping clustered volume group" out
# reset back to non-clustered VG with disabled locking
2014-09-17 16:27:46 +04:00
vgchange -cn $vg --config 'global{locking_type=0}' $vg
2014-05-22 14:00:59 +04:00
fi
check vg_attr_bit cluster $vg "-"
2008-11-11 18:29:24 +03:00
2014-02-27 02:25:30 +04:00
vgremove -ff $vg