2012-03-16 17:00:05 +04:00
#!/bin/sh
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,
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
2014-06-06 19:40:04 +04:00
. lib/inittest
2010-06-29 00:36:06 +04:00
2015-05-09 02:59:18 +03:00
test -e LOCAL_LVMPOLLD && skip
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
2013-05-31 23:11:51 +04:00
vgcreate $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
2011-01-05 03:16:18 +03:00
check vg_field $vg vg_mda_count $(( $mdacp * 2 ))
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
2011-01-05 03:16:18 +03:00
check vg_field $vg vg_mda_count $(( $mdacp * 2 ))
check vg_field $vg vg_mda_used_count $(( $mdacp * 2 ))
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
}
echo Test of vgmetadatacopies with vgcreate and vgchange
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 "
2013-05-31 23:11:51 +04:00
vgcreate $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
vgchange --metadatacopies $(( $mdacp * 1 )) $vg
echo --vgmetadatacopies is persistent on disk
echo --vgmetadatacopies affects underlying pv mda ignore
2011-01-05 03:16:18 +03:00
check vg_field $vg vg_mda_copies $(( $mdacp * 1 ))
check vg_field $vg vg_mda_used_count $(( $mdacp * 1 ))
2010-06-29 00:40:27 +04:00
vgchange --vgmetadatacopies $(( $mdacp * 2 )) $vg
2011-01-05 03:16:18 +03:00
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
vgchange --vgmetadatacopies $(( $mdacp * 5 )) $vg
2011-01-05 03:16:18 +03:00
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
echo vgcreate 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
2013-05-31 23:11:51 +04:00
vgcreate $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
echo vgcreate succeeds with a specific number of metadata copies
2013-05-31 23:11:51 +04:00
vgcreate --vgmetadatacopies $(( $mdacp * 2 )) $vg " $dev1 " " $dev2 "
2011-01-05 03:16:18 +03:00
check vg_field $vg vg_mda_copies $(( $mdacp * 2 ))
2010-06-29 00:40:27 +04:00
vgremove -f $vg
2013-05-31 23:11:51 +04:00
vgcreate --vgmetadatacopies $(( $mdacp * 1 )) $vg " $dev1 " " $dev2 "
2011-01-05 03:16:18 +03:00
check vg_field $vg vg_mda_copies $(( $mdacp * 1 ))
2010-06-29 00:40:27 +04:00
vgremove -f $vg
echo vgcreate succeeds with a larger value than total metadatacopies
2013-05-31 23:11:51 +04:00
vgcreate --vgmetadatacopies $(( $mdacp * 5 )) $vg " $dev1 " " $dev2 "
2011-01-05 03:16:18 +03:00
check vg_field $vg vg_mda_copies $(( $mdacp * 5 ))
2010-06-29 00:40:27 +04:00
vgremove -f $vg
echo vgcreate succeeds with --vgmetadatacopies unmanaged
2013-05-31 23:11:51 +04:00
vgcreate --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 "
2010-06-29 00:40:27 +04:00
echo vgcreate succeds with small value of --metadatacopies, ignores mdas
2013-05-31 23:11:51 +04:00
vgcreate --vgmetadatacopies 1 $vg " $dev1 " " $dev2 " " $dev4 " " $dev5 "
2011-01-05 03:16:18 +03:00
check vg_field $vg vg_mda_copies 1
check vg_field $vg vg_mda_count $(( $mdacp * 4 ))
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
2011-01-05 03:16:18 +03:00
check vg_field $vg vg_mda_count $(( $mdacp * 4 ))
check vg_field $vg vg_mda_copies unmanaged
check vg_field $vg vg_mda_used_count $(( $mdacp * 4 ))
2010-07-01 02:22:00 +04:00
echo --vgmetadatacopies 0 should be unmanaged for vgchange and vgcreate
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
2013-05-31 23:11:51 +04:00
vgcreate --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
2013-05-31 23:11:51 +04:00
vgcreate --vgmetadatacopies $(( $mdacp * 5 )) $vg " $dev1 " " $dev2 " " $dev3 "
2011-01-05 03:16:18 +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
2013-05-31 23:11:51 +04:00
vgcreate --vgmetadatacopies $(( $mdacp * 1 )) $vg " $dev1 " " $dev2 " " $dev3 "
2011-01-05 03:16:18 +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
2011-01-05 03:16:18 +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
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
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 "
2013-05-31 23:11:51 +04:00
vgcreate --vgmetadatacopies 2 $vg1 " $dev1 " " $dev2 " " $dev3 "
vgcreate --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
check vg_field $vg2 vg_mda_copies $(( $mdacp * 1 ))
2012-03-16 17:00:05 +04:00
vgsplit $vg1 $vg2 " $dev1 "
2011-01-05 03:16:18 +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
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
2012-03-16 17:00:05 +04:00
vgsplit --vgmetadatacopies $(( $mdacp * 2 )) $vg1 $vg2 " $dev1 " " $dev2 "
2011-01-05 03:16:18 +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
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 "
2013-05-31 23:11:51 +04:00
vgcreate --vgmetadatacopies $(( $mdacp * 1 )) $vg1 " $dev1 " " $dev2 "
2011-01-05 03:16:18 +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 "
2011-01-05 03:16:18 +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
2011-01-05 03:16:18 +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
2011-01-05 03:16:18 +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
2011-01-05 03:16:18 +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
2011-01-05 03:16:18 +03:00
check vg_field $vg1 vg_mda_used_count $(( $mdacp * 2 ))
2010-06-29 00:40:27 +04:00
vgremove -f $vg1
done