2017-07-02 22:38:32 +03:00
#!/usr/bin/env bash
2010-06-29 00:36:06 +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
2010-06-29 00:36:06 +04:00
2015-10-27 17:10:06 +03:00
SKIP_WITH_LVMPOLLD = 1
2010-06-29 00:36:06 +04:00
2015-10-27 17:10:06 +03:00
. lib/inittest
2015-05-09 02:59:18 +03:00
2010-06-29 00:40:27 +04:00
aux prepare_devs 6
2010-06-29 00:36:06 +04:00
2010-06-29 00:40:27 +04:00
echo Make sure we can ignore / un-ignore mdas on a per-PV basis
2010-06-29 00:36:06 +04:00
for pv_in_vg in 1 0; do
for mdacp in 1 2; do
2012-03-16 17:00:05 +04:00
pvcreate --metadatacopies $mdacp " $dev1 " " $dev2 "
pvcreate --metadatacopies 0 " $dev3 "
2010-06-29 00:36:06 +04:00
if [ $pv_in_vg = 1 ] ; then
2018-05-31 23:12:34 +03:00
vgcreate $SHARED $vg " $dev1 " " $dev2 " " $dev3 "
2010-06-29 00:36:06 +04:00
fi
2012-03-16 17:00:05 +04:00
pvchange --metadataignore y " $dev1 "
check pv_field " $dev1 " pv_mda_count $mdacp
check pv_field " $dev1 " pv_mda_used_count 0
check pv_field " $dev2 " pv_mda_count $mdacp
check pv_field " $dev2 " pv_mda_used_count $mdacp
2010-06-29 00:36:06 +04:00
if [ $pv_in_vg = 1 ] ; then
2017-07-06 20:27:04 +03:00
check vg_field $vg vg_mda_count $(( mdacp * 2 ))
2011-01-05 03:16:18 +03:00
check vg_field $vg vg_mda_used_count $mdacp
check vg_field $vg vg_mda_copies unmanaged
2010-06-29 00:36:06 +04:00
fi
2012-03-16 17:00:05 +04:00
pvchange --metadataignore n " $dev1 "
check pv_field " $dev1 " pv_mda_count $mdacp
check pv_field " $dev1 " pv_mda_used_count $mdacp
2010-06-29 00:36:06 +04:00
if [ $pv_in_vg = 1 ] ; then
2017-07-06 20:27:04 +03:00
check vg_field $vg vg_mda_count $(( mdacp * 2 ))
check vg_field $vg vg_mda_used_count $(( mdacp * 2 ))
2011-01-05 03:16:18 +03:00
check vg_field $vg vg_mda_copies unmanaged
2010-06-29 00:36:06 +04:00
vgremove -f $vg
fi
done
done
2010-06-29 00:40:27 +04:00
# Check if a PV has unignored (used) mdas, and if so, ignore
pvignore_ ( ) {
2011-01-05 03:16:18 +03:00
pv_mda_used_count = $( get pv_field " $1 " pv_mda_used_count)
2010-06-29 00:40:27 +04:00
if [ $pv_mda_used_count -ne 0 ] ; then
pvchange --metadataignore y $1
fi
}
# Check if a PV has ignored mdas, and if so, unignore (make used)
pvunignore_ ( ) {
2011-01-05 03:16:18 +03:00
pv_mda_count = $( get pv_field " $1 " pv_mda_count)
pv_mda_used_count = $( get pv_field " $1 " pv_mda_used_count)
2010-06-29 00:40:27 +04:00
if [ $pv_mda_count -gt $pv_mda_used_count ] ; then
pvchange --metadataignore n $1
fi
}
2018-05-31 23:12:34 +03:00
echo Test of vgmetadatacopies with vgcreate $SHARED and vgchange
2010-06-29 00:40:27 +04:00
for mdacp in 1 2; do
2012-03-16 17:00:05 +04:00
pvcreate --metadatacopies $mdacp " $dev1 " " $dev2 " " $dev4 " " $dev5 "
check pv_field " $dev1 " pv_mda_used_count $mdacp
check pv_field " $dev2 " pv_mda_used_count $mdacp
check pv_field " $dev4 " pv_mda_used_count $mdacp
check pv_field " $dev5 " pv_mda_used_count $mdacp
pvcreate --metadatacopies 0 " $dev3 "
2018-05-31 23:12:34 +03:00
vgcreate $SHARED $vg " $dev1 " " $dev2 " " $dev3 "
2011-01-05 03:16:18 +03:00
check vg_field $vg vg_mda_copies unmanaged
2010-06-29 00:40:27 +04:00
echo ensure both --vgmetadatacopies and --metadatacopies accepted
2017-07-06 20:27:04 +03:00
vgchange --metadatacopies $(( mdacp * 1 )) $vg
2010-06-29 00:40:27 +04:00
echo --vgmetadatacopies is persistent on disk
echo --vgmetadatacopies affects underlying pv mda ignore
2017-07-06 20:27:04 +03:00
check vg_field $vg vg_mda_copies $(( mdacp * 1 ))
check vg_field $vg vg_mda_used_count $(( mdacp * 1 ))
vgchange --vgmetadatacopies $(( mdacp * 2 )) $vg
check vg_field $vg vg_mda_copies $(( mdacp * 2 ))
check vg_field $vg vg_mda_used_count $(( mdacp * 2 ))
2010-06-29 00:40:27 +04:00
echo allow setting metadatacopies larger than number of PVs
2017-07-06 20:27:04 +03:00
vgchange --vgmetadatacopies $(( mdacp * 5 )) $vg
check vg_field $vg vg_mda_copies $(( mdacp * 5 ))
check vg_field $vg vg_mda_used_count $(( mdacp * 2 ))
2010-06-29 00:40:27 +04:00
echo setting to 0 disables automatic balancing
vgchange --vgmetadatacopies unmanaged $vg
2011-01-05 03:16:18 +03:00
check vg_field $vg vg_mda_copies unmanaged
2010-06-29 00:40:27 +04:00
vgremove -f $vg
2018-05-31 23:12:34 +03:00
echo vgcreate $SHARED succeeds even when creating a VG w/all ignored mdas
2012-03-16 17:00:05 +04:00
pvchange --metadataignore y " $dev1 " " $dev2 "
check pv_field " $dev1 " pv_mda_count $mdacp
check pv_field " $dev2 " pv_mda_used_count 0
2018-05-31 23:12:34 +03:00
vgcreate $SHARED $vg " $dev1 " " $dev2 "
2011-01-05 03:16:18 +03:00
check vg_field $vg vg_mda_copies unmanaged
2010-06-29 00:40:27 +04:00
vgremove -f $vg
2018-05-31 23:12:34 +03:00
echo vgcreate $SHARED succeeds with a specific number of metadata copies
vgcreate $SHARED --vgmetadatacopies $(( mdacp * 2 )) $vg " $dev1 " " $dev2 "
2017-07-06 20:27:04 +03:00
check vg_field $vg vg_mda_copies $(( mdacp * 2 ))
2010-06-29 00:40:27 +04:00
vgremove -f $vg
2018-05-31 23:12:34 +03:00
vgcreate $SHARED --vgmetadatacopies $(( mdacp * 1 )) $vg " $dev1 " " $dev2 "
2017-07-06 20:27:04 +03:00
check vg_field $vg vg_mda_copies $(( mdacp * 1 ))
2010-06-29 00:40:27 +04:00
vgremove -f $vg
2018-05-31 23:12:34 +03:00
echo vgcreate $SHARED succeeds with a larger value than total metadatacopies
vgcreate $SHARED --vgmetadatacopies $(( mdacp * 5 )) $vg " $dev1 " " $dev2 "
2017-07-06 20:27:04 +03:00
check vg_field $vg vg_mda_copies $(( mdacp * 5 ))
2010-06-29 00:40:27 +04:00
vgremove -f $vg
2018-05-31 23:12:34 +03:00
echo vgcreate $SHARED succeeds with --vgmetadatacopies unmanaged
vgcreate $SHARED --vgmetadatacopies unmanaged $vg " $dev1 " " $dev2 "
2011-01-05 03:16:18 +03:00
check vg_field $vg vg_mda_copies unmanaged
2010-06-29 00:40:27 +04:00
vgremove -f $vg
2012-03-16 17:00:05 +04:00
pvunignore_ " $dev1 "
pvunignore_ " $dev2 "
pvunignore_ " $dev4 "
pvunignore_ " $dev5 "
2018-05-31 23:12:34 +03:00
echo vgcreate $SHARED succeds with small value of --metadatacopies, ignores mdas
vgcreate $SHARED --vgmetadatacopies 1 $vg " $dev1 " " $dev2 " " $dev4 " " $dev5 "
2011-01-05 03:16:18 +03:00
check vg_field $vg vg_mda_copies 1
2017-07-06 20:27:04 +03:00
check vg_field $vg vg_mda_count $(( mdacp * 4 ))
2011-01-05 03:16:18 +03:00
check vg_field $vg vg_mda_used_count 1
2010-06-29 00:40:27 +04:00
echo Setting a larger value should trigger non-ignore of mdas
vgchange --metadatacopies 3 $vg
2011-01-05 03:16:18 +03:00
check vg_field $vg vg_mda_copies 3
check vg_field $vg vg_mda_used_count 3
2010-06-29 00:40:27 +04:00
echo Setting all should trigger unignore of all mdas
vgchange --vgmetadatacopies all $vg
2017-07-06 20:27:04 +03:00
check vg_field $vg vg_mda_count $(( mdacp * 4 ))
2011-01-05 03:16:18 +03:00
check vg_field $vg vg_mda_copies unmanaged
2017-07-06 20:27:04 +03:00
check vg_field $vg vg_mda_used_count $(( mdacp * 4 ))
2018-05-31 23:12:34 +03:00
echo --vgmetadatacopies 0 should be unmanaged for vgchange and vgcreate $SHARED
2010-07-01 02:22:00 +04:00
vgchange --vgmetadatacopies 0 $vg
2011-01-05 03:16:18 +03:00
check vg_field $vg vg_mda_copies unmanaged
2010-07-01 02:22:00 +04:00
vgremove -f $vg
2018-05-31 23:12:34 +03:00
vgcreate $SHARED --vgmetadatacopies 0 $vg " $dev1 " " $dev2 " " $dev4 " " $dev5 "
2011-01-05 03:16:18 +03:00
check vg_field $vg vg_mda_copies unmanaged
2010-06-29 00:40:27 +04:00
vgremove -f $vg
done
echo Test vgextend / vgreduce with vgmetadatacopies
for mdacp in 1 2; do
2012-03-16 17:00:05 +04:00
pvcreate --metadatacopies $mdacp " $dev1 " " $dev2 " " $dev4 " " $dev5 "
pvcreate --metadatacopies 0 " $dev3 "
2010-06-29 00:40:27 +04:00
echo Set a large value of vgmetadatacopies
2018-05-31 23:12:34 +03:00
vgcreate $SHARED --vgmetadatacopies $(( mdacp * 5 )) $vg " $dev1 " " $dev2 " " $dev3 "
2017-07-06 20:27:04 +03:00
check vg_field $vg vg_mda_copies $(( mdacp * 5 ))
2010-06-29 00:40:27 +04:00
echo Ignore mdas on devices to be used for vgextend
echo Large value of vgetadatacopies should automatically un-ignore mdas
2012-03-16 17:00:05 +04:00
pvchange --metadataignore y " $dev4 " " $dev5 "
check pv_field " $dev4 " pv_mda_used_count 0
vgextend $vg " $dev4 " " $dev5 "
check pv_field " $dev4 " pv_mda_used_count $mdacp
check pv_field " $dev5 " pv_mda_used_count $mdacp
2010-06-29 00:40:27 +04:00
vgremove -f $vg
echo Set a small value of vgmetadatacopies
2018-05-31 23:12:34 +03:00
vgcreate $SHARED --vgmetadatacopies $(( mdacp * 1 )) $vg " $dev1 " " $dev2 " " $dev3 "
2017-07-06 20:27:04 +03:00
check vg_field $vg vg_mda_copies $(( mdacp * 1 ))
2010-06-29 00:40:27 +04:00
echo Ignore mdas on devices to be used for vgextend
echo Small value of vgetadatacopies should leave mdas as ignored
2012-03-16 17:00:05 +04:00
pvchange --metadataignore y " $dev4 " " $dev5 "
check pv_field " $dev4 " pv_mda_used_count 0
vgextend $vg " $dev4 " " $dev5 "
check pv_field " $dev4 " pv_mda_used_count 0
check pv_field " $dev5 " pv_mda_used_count 0
2010-06-29 00:40:27 +04:00
echo vgreduce of ignored pv w/mda should not trigger any change to ignore bits
2012-03-16 17:00:05 +04:00
vgreduce $vg " $dev4 "
check pv_field " $dev4 " pv_mda_used_count 0
check pv_field " $dev5 " pv_mda_used_count 0
2010-06-29 00:40:27 +04:00
echo vgreduce of un-ignored pv w/mda should trigger un-ignore on an mda
2012-03-16 17:00:05 +04:00
vgreduce $vg " $dev1 " " $dev2 " " $dev3 "
check pv_field " $dev5 " pv_mda_used_count $mdacp
2017-07-06 20:27:04 +03:00
check vg_field $vg vg_mda_copies $(( mdacp * 1 ))
2012-03-16 17:00:05 +04:00
pvunignore_ " $dev1 "
pvunignore_ " $dev2 "
2010-06-29 00:40:27 +04:00
echo setting vgmetadatacopies to unmanaged should allow vgextend to add w/out balancing
vgchange --vgmetadatacopies unmanaged $vg
2012-03-16 17:00:05 +04:00
vgextend $vg " $dev1 " " $dev2 "
2011-01-05 03:16:18 +03:00
check vg_field $vg vg_mda_copies unmanaged
2017-07-06 20:27:04 +03:00
check vg_field $vg vg_mda_count $(( mdacp * 3 ))
check vg_field $vg vg_mda_used_count $(( mdacp * 3 ))
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-29 00:40:27 +04:00
vgremove -f $vg
done
2018-05-31 23:12:34 +03:00
if test -n " $LVM_TEST_LVMLOCKD " ; then
echo skip vgsplit and vgmerge with lvmlockd
else
2010-06-29 00:40:27 +04:00
echo Test special situations, vgsplit, vgmerge, etc
for mdacp in 1 2; do
2012-03-16 17:00:05 +04:00
pvcreate --metadatacopies $mdacp " $dev1 " " $dev2 " " $dev3 " " $dev4 " " $dev5 "
2018-05-31 23:12:34 +03:00
vgcreate $SHARED --vgmetadatacopies 2 $vg1 " $dev1 " " $dev2 " " $dev3 "
vgcreate $SHARED --vgmetadatacopies $(( mdacp * 1 )) $vg2 " $dev4 " " $dev5 "
2010-06-29 00:40:27 +04:00
echo vgsplit/vgmerge preserves value of metadata copies
2011-01-05 03:16:18 +03:00
check vg_field $vg1 vg_mda_copies 2
2017-07-06 20:27:04 +03:00
check vg_field $vg2 vg_mda_copies $(( mdacp * 1 ))
2012-03-16 17:00:05 +04:00
vgsplit $vg1 $vg2 " $dev1 "
2017-07-06 20:27:04 +03:00
check vg_field $vg2 vg_mda_copies $(( mdacp * 1 ))
2010-06-29 00:40:27 +04:00
vgmerge $vg1 $vg2
2011-01-05 03:16:18 +03:00
check vg_field $vg1 vg_mda_copies 2
2017-07-06 20:27:04 +03:00
check vg_field $vg1 vg_mda_count $(( mdacp * 5 ))
2010-06-29 00:40:27 +04:00
echo vgsplit into new vg sets proper value of vgmetadatacopies
2017-10-30 19:26:42 +03:00
vgsplit --vgmetadatacopies $(( mdacp * 2 )) $vg1 $vg2 " $dev1 " " $dev2 "
2017-07-06 20:27:04 +03:00
check vg_field $vg2 vg_mda_copies $(( mdacp * 2 ))
2010-06-29 00:40:27 +04:00
echo vgchange fails if given both vgmetadatacopies and metadatacopies
not vgchange --vgmetadatacopies 5 --metadatacopies 7 $vg2
2012-03-16 17:00:05 +04:00
vgremove -f $vg1 $vg2
2010-06-29 00:40:27 +04:00
done
2018-05-31 23:12:34 +03:00
fi
2010-06-29 00:40:27 +04:00
echo Test combination of --vgmetadatacopies and pvchange --metadataignore
for mdacp in 1 2; do
2012-03-16 17:00:05 +04:00
pvcreate --metadatacopies $mdacp " $dev1 " " $dev2 " " $dev3 " " $dev4 " " $dev5 "
2018-05-31 23:12:34 +03:00
vgcreate $SHARED --vgmetadatacopies $(( mdacp * 1 )) $vg1 " $dev1 " " $dev2 "
2017-07-06 20:27:04 +03:00
check vg_field $vg1 vg_mda_copies $(( mdacp * 1 ))
check vg_field $vg1 vg_mda_used_count $(( mdacp * 1 ))
2012-03-16 17:00:05 +04:00
pvignore_ " $dev3 "
2010-06-29 00:40:27 +04:00
echo Ensure vgextend of PVs with ignored MDAs does not add to vg_mda_used_count
2012-03-16 17:00:05 +04:00
vgextend $vg1 " $dev3 "
2017-07-06 20:27:04 +03:00
check vg_field $vg1 vg_mda_used_count $(( mdacp * 1 ))
2010-06-29 00:40:27 +04:00
echo Using pvchange to unignore should update vg_mda_used_count
2012-03-16 17:00:05 +04:00
pvchange -f --metadataignore n " $dev3 "
check pv_field " $dev3 " pv_mda_used_count $mdacp
2017-07-06 20:27:04 +03:00
check vg_field $vg1 vg_mda_used_count $(( mdacp * 2 ))
2010-06-29 00:40:27 +04:00
echo Set unmanaged on the vg should keep ignore bits the same during vgextend
vgchange --vgmetadatacopies unmanaged $vg1
2017-07-06 20:27:04 +03:00
check vg_field $vg1 vg_mda_used_count $(( mdacp * 2 ))
2012-03-16 17:00:05 +04:00
pvunignore_ " $dev4 "
vgextend $vg1 " $dev4 "
check pv_field " $dev4 " pv_mda_used_count $mdacp
2017-07-06 20:27:04 +03:00
check vg_field $vg1 vg_mda_used_count $(( mdacp * 3 ))
2010-06-29 00:40:27 +04:00
echo Using pvchange to ignore should update vg_mda_used_count
2012-03-16 17:00:05 +04:00
pvchange -f --metadataignore y " $dev4 "
check pv_field " $dev4 " pv_mda_used_count 0
2017-07-06 20:27:04 +03:00
check vg_field $vg1 vg_mda_used_count $(( mdacp * 2 ))
2010-06-29 00:40:27 +04:00
vgremove -f $vg1
done