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