2012-03-16 17:00:05 +04:00
#!/bin/sh
2009-01-09 13:16:57 +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,
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
2014-06-06 19:40:04 +04:00
. lib/inittest
2009-01-09 13:16:57 +03:00
2011-01-28 19:13:39 +03:00
aux prepare_vg 3 12
2009-01-09 13:16:57 +03:00
2013-08-08 00:48:31 +04:00
lvcreate -aye --type mirror -m 1 -l 1 -n mirror $vg
2009-01-09 13:16:57 +03:00
lvcreate -l 1 -n resized $vg
lvchange -a n $vg /mirror
2011-01-05 03:16:18 +03:00
aux backup_dev $( cat DEVICES)
2009-01-09 13:16:57 +03:00
init( ) {
2011-01-05 03:16:18 +03:00
aux restore_dev $( cat DEVICES)
2013-06-15 13:21:03 +04:00
not check lv_field $vg /resized lv_size "8.00m"
2009-01-09 13:16:57 +03:00
lvresize -L 8192K $vg /resized
2012-03-16 17:00:05 +04:00
aux restore_dev " $dev1 "
2009-01-09 13:16:57 +03:00
}
2009-06-06 00:00:52 +04:00
2012-03-28 11:46:35 +04:00
# vgscan fixes up metadata (needs --cache option for direct scan if lvmetad is used)
test -e LOCAL_LVMETAD && cache = "--cache"
2009-01-09 13:16:57 +03:00
init
2012-03-28 11:46:35 +04:00
vgscan $cache 2>& 1 | tee cmd.out
2009-01-09 13:16:57 +03:00
grep " Inconsistent metadata found for VG $vg " cmd.out
2012-09-20 03:57:55 +04:00
test -e LOCAL_LVMETAD && vgrename $vg foo && vgrename foo $vg # trigger a write
2012-03-28 11:46:35 +04:00
vgscan $cache 2>& 1 | tee cmd.out
2009-01-09 13:16:57 +03:00
not grep " Inconsistent metadata found for VG $vg " cmd.out
2013-06-15 13:21:03 +04:00
check lv_field $vg /resized lv_size "8.00m"
2009-01-09 13:16:57 +03:00
2012-02-23 17:11:07 +04:00
# only vgscan would have noticed metadata inconsistencies when lvmetad is active
2013-06-04 12:37:08 +04:00
if test ! -e LOCAL_LVMETAD; then
2012-02-23 17:11:07 +04:00
# vgdisplay fixes
init
2012-03-16 17:00:05 +04:00
vgdisplay $vg 2>& 1 | tee cmd.out
2012-02-23 17:11:07 +04:00
grep " Inconsistent metadata found for VG $vg " cmd.out
2012-03-16 17:00:05 +04:00
vgdisplay $vg 2>& 1 | tee cmd.out
2012-02-23 17:11:07 +04:00
not grep " Inconsistent metadata found for VG $vg " cmd.out
2013-06-15 13:21:03 +04:00
check lv_field $vg /resized lv_size "8.00m"
2009-01-09 13:16:57 +03:00
2012-02-23 17:11:07 +04:00
# lvs fixes up
init
2012-03-16 17:00:05 +04:00
lvs $vg 2>& 1 | tee cmd.out
2012-02-23 17:11:07 +04:00
grep " Inconsistent metadata found for VG $vg " cmd.out
2012-03-16 17:00:05 +04:00
vgdisplay $vg 2>& 1 | tee cmd.out
2012-02-23 17:11:07 +04:00
not grep " Inconsistent metadata found for VG $vg " cmd.out
2013-06-15 13:21:03 +04:00
check lv_field $vg /resized lv_size "8.00m"
2009-01-09 13:16:57 +03:00
2012-02-23 17:11:07 +04:00
# vgs fixes up as well
init
2012-03-16 17:00:05 +04:00
vgs $vg 2>& 1 | tee cmd.out
2012-02-23 17:11:07 +04:00
grep " Inconsistent metadata found for VG $vg " cmd.out
2012-03-16 17:00:05 +04:00
vgs $vg 2>& 1 | tee cmd.out
2012-02-23 17:11:07 +04:00
not grep " Inconsistent metadata found for VG $vg " cmd.out
2013-06-15 13:21:03 +04:00
check lv_field $vg /resized lv_size "8.00m"
2012-02-23 17:11:07 +04:00
fi
2010-07-07 18:43:57 +04:00
echo Check auto-repair of failed vgextend - metadata written to original pv but not new pv
vgremove -f $vg
2011-01-05 03:16:18 +03:00
pvremove -ff $( cat DEVICES)
pvcreate $( cat DEVICES)
2012-03-16 17:00:05 +04:00
aux backup_dev " $dev2 "
vgcreate $vg " $dev1 "
vgextend $vg " $dev2 "
aux restore_dev " $dev2 "
2013-06-04 12:37:08 +04:00
vgscan $cache
2012-03-16 17:00:05 +04:00
should check compare_fields vgs $vg vg_mda_count pvs " $dev2 " vg_mda_count
2014-02-27 02:25:30 +04:00
vgremove -ff $vg