2012-03-16 17:00:05 +04:00
#!/bin/sh
# Copyright (C) 2011-2012 Red Hat, Inc. All rights reserved.
2011-07-18 16:04:42 +04:00
#
# 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
2011-07-18 16:04:42 +04:00
2016-02-23 01:13:42 +03:00
SKIP_WITH_LVMLOCKD = 1
2015-10-27 17:10:06 +03:00
SKIP_WITH_LVMPOLLD = 1
2011-07-18 16:04:42 +04:00
2015-10-27 17:10:06 +03:00
. lib/inittest
2015-05-09 02:59:18 +03:00
2011-07-18 16:04:42 +04:00
aux prepare_vg 3
# fail multiple devices
2012-03-16 17:00:05 +04:00
for i in " $dev1 " " $dev2 " " $dev3 " ; do
for j in " $dev2 " " $dev3 " ; do
if test " $i " = " $j " ; then continue ; fi
2011-07-18 16:04:42 +04:00
vgremove -ff $vg
2012-03-16 17:00:05 +04:00
vgcreate $vg " $dev1 " " $dev2 " " $dev3 "
2012-02-23 17:11:07 +04:00
# exit 1
2011-07-18 16:04:42 +04:00
2012-03-16 17:00:05 +04:00
lvcreate -l1 -n $lv1 $vg " $dev1 "
2011-07-18 16:04:42 +04:00
2012-03-16 17:00:05 +04:00
aux disable_dev " $i " " $j "
2011-07-18 16:04:42 +04:00
vgreduce --removemissing --force $vg
# check if reduced device was removed
2012-03-28 15:10:08 +04:00
test " $i " = " $dev1 " && dm_table | not egrep " $vg - $lv1 : *[^ ]+ "
2011-07-18 16:04:42 +04:00
lvcreate -l1 -n $lv2 $vg
2012-03-16 17:00:05 +04:00
test " $i " != " $dev1 " && check lv_exists $vg $lv1
2011-07-18 16:04:42 +04:00
check lv_exists $vg $lv2
2012-03-16 17:00:05 +04:00
aux enable_dev " $i " " $j "
2012-02-23 18:55:29 +04:00
vgscan
2011-07-18 16:04:42 +04:00
2012-03-16 17:00:05 +04:00
test " $i " != " $dev1 " && check lv_exists $vg $lv1
2011-07-18 16:04:42 +04:00
check lv_exists $vg $lv2
done
done
vgremove -ff $vg
2012-03-16 17:00:05 +04:00
vgcreate $vg " $dev1 " " $dev2 " " $dev3 "
2011-07-18 16:04:42 +04:00
# use tricky 'dd'
for i in " $dev1 " " $dev2 " " $dev3 " ; do
for j in " $dev2 " " $dev3 " ; do
if test " $i " = " $j " ; then continue ; fi
dd if = " $i " of = backup_i bs = 256K count = 1
dd if = " $j " of = backup_j bs = 256K count = 1
2012-03-16 17:00:05 +04:00
lvcreate -l1 -n $lv1 $vg " $dev1 "
2011-07-18 16:04:42 +04:00
dd if = backup_j of = " $j " bs = 256K count = 1
dd if = backup_i of = " $i " bs = 256K count = 1
check lv_exists $vg $lv1
# mda should be now consistent
lvremove -f $vg /$lv1
done
done
# confuse lvm with active LV left behind
dd if = " $dev1 " of = backup_i bs = 256K count = 1
dd if = " $dev2 " of = backup_j bs = 256K count = 1
2012-03-16 17:00:05 +04:00
lvcreate -l1 $vg " $dev1 "
2011-07-18 16:04:42 +04:00
dd if = backup_j of = " $dev2 " bs = 256K count = 1
dd if = backup_i of = " $dev1 " bs = 256K count = 1
# CHECKME: following command writes here:
# vgreduce --removemissing --force $vg
#
# WARNING: Inconsistent metadata found for VG LVMTESTvg - updating to use version 2
# Volume group "LVMTESTvg" is already consistent
# dirty game
dd if = /dev/zero of = " $dev3 " bs = 256K count = 1
2012-03-16 17:00:05 +04:00
aux notify_lvmetad " $dev3 " # udev be watching you
2011-07-18 16:04:42 +04:00
vgreduce --removemissing --force $vg
# FIXME: here is LV1 left active - but metadata does not know about it
# and lvcreate does not check whether such device exists in the table
# so it ends with:
#
# device-mapper: create ioctl failed: Device or resource busy
# Failed to activate new LV.
2012-03-16 17:00:05 +04:00
should lvcreate -l1 $vg " $dev1 "
2016-12-11 12:24:06 +03:00
should not dmsetup remove ${ vg } -lvol0
vgremove -ff $vg