2010-04-12 19:16:24 +00:00
#!/bin/sh
2013-05-31 21:11:51 +02:00
# Copyright (C) 2010-2013 Red Hat, Inc. All rights reserved.
2010-04-12 19:16:24 +00: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,
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
2014-07-21 21:44:53 +02:00
# disable lvmetad logging as it bogs down test systems
2015-05-01 14:45:47 +02:00
export LVM_TEST_LVMETAD_DEBUG_OPTS = ${ LVM_TEST_LVMETAD_DEBUG_OPTS - }
. lib/inittest
2014-07-21 21:44:53 +02:00
2012-03-04 16:02:19 +00:00
aux prepare_pvs 5 10
2013-05-31 21:11:51 +02:00
# proper DEVRANGE needs to be set according to extent size
DEVRANGE = "0-32"
vgcreate -s 32k $vg $( cat DEVICES)
2012-03-04 16:02:19 +00:00
2013-06-19 17:50:10 -05:00
# convert from linear to 2-way mirror ("mirror" default type)
2013-05-31 21:11:51 +02:00
lvcreate -aey -l2 -n $lv1 $vg " $dev1 "
2013-06-19 17:50:10 -05:00
lvconvert -i1 -m+1 $vg /$lv1 " $dev2 " " $dev3 :0-1 " \
--config 'global { mirror_segtype_default = "mirror" }'
2013-09-25 22:25:43 -05:00
lvs --noheadings -o attr $vg /$lv1 | grep '^[[:space:]]*m'
2013-06-19 17:50:10 -05:00
lvremove -ff $vg
# convert from linear to 2-way mirror (override "raid1" default type)
lvcreate -aey -l2 -n $lv1 $vg " $dev1 "
2013-08-07 15:48:31 -05:00
lvconvert -i1 --type mirror -m+1 $vg /$lv1 " $dev2 " " $dev3 :0-1 " \
2013-06-19 17:50:10 -05:00
--config 'global { mirror_segtype_default = "raid1" }'
2013-09-25 22:25:43 -05:00
lvs --noheadings -o attr $vg /$lv1 | grep '^[[:space:]]*m'
2012-03-04 16:02:19 +00:00
lvremove -ff $vg
2010-04-12 19:16:24 +00:00
2012-05-05 02:08:46 +00:00
# convert from linear to 2-way mirror - with tags and volume_list (bz683270)
2013-05-31 21:11:51 +02:00
lvcreate -aey -l2 -n $lv1 $vg --addtag hello
2013-08-07 15:48:31 -05:00
lvconvert -i1 --type mirror -m+1 $vg /$lv1 \
2012-05-05 02:08:46 +00:00
--config 'activation { volume_list = [ "@hello" ] }'
lvremove -ff $vg
# convert from 2-way to 3-way mirror - with tags and volume_list (bz683270)
2013-08-07 15:48:31 -05:00
lvcreate -aey -l2 --type mirror -m1 -n $lv1 $vg --addtag hello
2012-05-05 02:08:46 +00:00
lvconvert -i1 -m+1 $vg /$lv1 \
--config 'activation { volume_list = [ "@hello" ] }'
lvremove -ff $vg
2010-04-12 19:16:24 +00:00
# convert from 2-way mirror to linear
2013-08-07 15:48:31 -05:00
lvcreate -aey -l2 --type mirror -m1 -n $lv1 $vg " $dev1 " " $dev2 " " $dev3 :0-1 "
2010-04-12 19:16:24 +00:00
lvconvert -m-1 $vg /$lv1
check linear $vg $lv1
lvremove -ff $vg
2010-04-12 19:32:58 +00:00
# and now try removing a specific leg (bz453643)
2013-08-07 15:48:31 -05:00
lvcreate -aey -l2 --type mirror -m1 -n $lv1 $vg " $dev1 " " $dev2 " " $dev3 :0-1 "
2012-03-16 13:00:05 +00:00
lvconvert -m0 $vg /$lv1 " $dev2 "
check lv_on $vg $lv1 " $dev1 "
2010-04-12 19:32:58 +00:00
lvremove -ff $vg
2010-04-12 19:16:24 +00:00
# convert from disklog to corelog, active
2013-08-07 15:48:31 -05:00
lvcreate -aey -l2 --type mirror -m1 -n $lv1 $vg " $dev1 " " $dev2 " " $dev3 :0-1 "
2010-04-12 19:16:24 +00:00
lvconvert -f --mirrorlog core $vg /$lv1
2010-05-12 10:08:35 +00:00
check mirror $vg $lv1 core
2010-04-12 19:16:24 +00:00
lvremove -ff $vg
# convert from corelog to disklog, active
2013-08-07 15:48:31 -05:00
lvcreate -aey -l2 --type mirror -m1 --mirrorlog core -n $lv1 $vg " $dev1 " " $dev2 "
2012-03-16 13:00:05 +00:00
lvconvert --mirrorlog disk $vg /$lv1 " $dev3 :0-1 "
check mirror $vg $lv1 " $dev3 "
2010-04-12 19:16:24 +00:00
lvremove -ff $vg
# convert linear to 2-way mirror with 1 PV
2013-05-31 21:11:51 +02:00
lvcreate -aey -l2 -n $lv1 $vg " $dev1 "
2012-03-16 13:00:05 +00:00
not lvconvert -m+1 --mirrorlog core $vg /$lv1 " $dev1 "
2010-04-12 19:16:24 +00:00
lvremove -ff $vg
2010-04-12 19:32:58 +00:00
2010-04-21 13:55:08 +00:00
# Start w/ 3-way mirror
# Test pulling primary image before mirror in-sync (should fail)
# Test pulling primary image after mirror in-sync (should work)
# Test that the correct devices remain in the mirror
2013-08-07 15:48:31 -05:00
lvcreate -aey -l2 --type mirror -m2 -n $lv1 $vg " $dev1 " " $dev2 " " $dev4 " " $dev3 : $DEVRANGE "
2010-04-21 13:55:08 +00:00
# FIXME:
# This is somewhat timing dependent - sync /could/ finish before
# we get a chance to have this command fail
2012-03-16 13:00:05 +00:00
should not lvconvert -m-1 $vg /$lv1 " $dev1 "
2010-05-12 10:08:35 +00:00
lvconvert $vg /$lv1 # wait
2012-03-16 13:00:05 +00:00
lvconvert -m2 $vg /$lv1 " $dev1 " " $dev2 " " $dev4 " " $dev3 :0 " # If the above "should" failed...
2010-05-12 06:09:22 +00:00
2012-07-24 14:20:30 -05:00
aux wait_for_sync $vg $lv1
2012-03-16 13:00:05 +00:00
lvconvert -m-1 $vg /$lv1 " $dev1 "
check mirror_images_on $lv1 " $dev2 " " $dev4 "
lvconvert -m-1 $vg /$lv1 " $dev2 "
2010-04-12 19:32:58 +00:00
check linear $vg $lv1
2012-03-16 13:00:05 +00:00
check lv_on $vg $lv1 " $dev4 "
2012-03-04 16:02:19 +00:00
lvremove -ff $vg
2010-05-12 10:08:35 +00:00
# No parallel lvconverts on a single LV please
2013-08-07 15:48:31 -05:00
lvcreate -aey -l5 --type mirror -m1 -n $lv1 $vg " $dev1 " " $dev2 " " $dev3 :0 "
2010-05-12 10:08:35 +00:00
check mirror $vg $lv1
check mirror_legs $vg $lv1 2
2015-04-28 15:31:47 +02:00
LVM_TEST_TAG = " kill_me_ $PREFIX " lvconvert -m+1 -b $vg /$lv1 " $dev4 "
2010-05-12 10:08:35 +00:00
# Next convert should fail b/c we can't have 2 at once
2012-03-16 13:00:05 +00:00
should not lvconvert -m+1 $vg /$lv1 " $dev5 "
2010-05-12 10:08:35 +00:00
lvconvert $vg /$lv1 # wait
lvconvert -m2 $vg /$lv1 # In case the above "should" actually failed
2012-03-16 13:00:05 +00:00
check mirror $vg $lv1 " $dev3 "
2010-05-12 10:08:35 +00:00
check mirror_no_temporaries $vg $lv1
check mirror_legs $vg $lv1 3
2012-03-04 16:02:19 +00:00
lvremove -ff $vg
2010-05-12 10:08:35 +00:00
# add 1 mirror to core log mirror, but
# implicitly keep log as 'core'
2013-08-07 15:48:31 -05:00
lvcreate -aey -l2 --type mirror -m1 --mirrorlog core -n $lv1 $vg " $dev1 " " $dev2 "
2010-05-12 10:08:35 +00:00
lvconvert -m +1 -i1 $vg /$lv1
check mirror $vg $lv1 core
check mirror_no_temporaries $vg $lv1
check mirror_legs $vg $lv1 3
2012-03-04 16:02:19 +00:00
lvremove -ff $vg
2010-05-12 10:08:35 +00:00
# remove 1 mirror from corelog'ed mirror; should retain 'core' log type
2013-08-07 15:48:31 -05:00
lvcreate -aey -l2 --type mirror -m2 --corelog -n $lv1 $vg
2010-05-12 10:08:35 +00:00
lvconvert -m -1 -i1 $vg /$lv1
check mirror $vg $lv1 core
check mirror_no_temporaries $vg $lv1
check mirror_legs $vg $lv1 2
2012-03-04 16:02:19 +00:00
lvremove -ff $vg
2010-05-12 10:08:35 +00:00
# add 1 mirror then add 1 more mirror during conversion
# FIXME this has been explicitly forbidden?
2013-08-07 15:48:31 -05:00
#lvcreate -l2 --type mirror -m1 -n $lv1 $vg "$dev1" "$dev2" "$dev3":0
2012-03-16 13:00:05 +00:00
#lvconvert -m+1 -b $vg/$lv1 "$dev4"
#lvconvert -m+1 $vg/$lv1 "$dev5"
2010-05-12 10:08:35 +00:00
#
2012-03-16 13:00:05 +00:00
#check mirror $vg $lv1 "$dev3"
2010-05-12 10:08:35 +00:00
#check mirror_no_temporaries $vg $lv1
#check mirror_legs $vg $lv1 4
2012-03-04 16:02:19 +00:00
#lvremove -ff $vg
2010-05-12 10:08:35 +00:00
# convert inactive mirror and start polling
2013-08-07 15:48:31 -05:00
lvcreate -aey -l2 --type mirror -m1 -n $lv1 $vg " $dev1 " " $dev2 " " $dev3 : $DEVRANGE "
2010-05-12 10:08:35 +00:00
lvchange -an $vg /$lv1
2012-03-16 13:00:05 +00:00
lvconvert -m+1 $vg /$lv1 " $dev4 "
2013-05-31 21:11:51 +02:00
lvchange -aey $vg /$lv1
2010-05-12 10:08:35 +00:00
lvconvert $vg /$lv1 # wait
2012-03-16 13:00:05 +00:00
check mirror $vg $lv1 " $dev3 "
2010-05-12 10:08:35 +00:00
check mirror_no_temporaries $vg $lv1
2012-03-04 16:02:19 +00:00
lvremove -ff $vg
2010-05-12 10:08:35 +00:00
# ---------------------------------------------------------------------
# removal during conversion
# "remove newly added mirror"
2013-08-07 15:48:31 -05:00
lvcreate -aey -l2 --type mirror -m1 -n $lv1 $vg " $dev1 " " $dev2 " " $dev3 : $DEVRANGE "
2015-04-28 15:31:47 +02:00
LVM_TEST_TAG = " kill_me_ $PREFIX " lvconvert -m+1 -b $vg /$lv1 " $dev4 "
2012-03-16 13:00:05 +00:00
lvconvert -m-1 $vg /$lv1 " $dev4 "
2010-05-12 10:08:35 +00:00
lvconvert $vg /$lv1 # wait
2012-03-16 13:00:05 +00:00
check mirror $vg $lv1 " $dev3 "
2010-05-12 10:08:35 +00:00
check mirror_no_temporaries $vg $lv1
check mirror_legs $vg $lv1 2
2012-03-04 16:02:19 +00:00
lvremove -ff $vg
2010-05-12 10:08:35 +00:00
# "remove one of newly added mirrors"
2013-08-07 15:48:31 -05:00
lvcreate -aey -l2 --type mirror -m1 -n $lv1 $vg " $dev1 " " $dev2 " " $dev3 : $DEVRANGE "
2015-04-28 15:31:47 +02:00
LVM_TEST_TAG = " kill_me_ $PREFIX " lvconvert -m+2 -b $vg /$lv1 " $dev4 " " $dev5 "
2012-03-16 13:00:05 +00:00
lvconvert -m-1 $vg /$lv1 " $dev4 "
2010-05-12 10:08:35 +00:00
lvconvert $vg /$lv1 # wait
2012-03-16 13:00:05 +00:00
check mirror $vg $lv1 " $dev3 "
2010-05-12 10:08:35 +00:00
check mirror_no_temporaries $vg $lv1
check mirror_legs $vg $lv1 3
2012-03-04 16:02:19 +00:00
lvremove -ff $vg
2010-05-12 10:08:35 +00:00
# "remove from original mirror (the original is still mirror)"
2013-08-07 15:48:31 -05:00
lvcreate -aey -l2 --type mirror -m2 -n $lv1 $vg " $dev1 " " $dev2 " " $dev5 " " $dev3 : $DEVRANGE "
2015-04-28 15:31:47 +02:00
LVM_TEST_TAG = " kill_me_ $PREFIX " lvconvert -m+1 -b $vg /$lv1 " $dev4 "
2014-02-24 10:56:02 +01:00
# FIXME: Extra wait here for mirror upconvert synchronization
# otherwise we may fail her on parallel upconvert and downconvert
# lvconvert-mirror-updown.sh tests this errornous case separately
lvconvert $vg /$lv1
2012-03-16 13:00:05 +00:00
lvconvert -m-1 $vg /$lv1 " $dev2 "
lvconvert $vg /$lv1
2010-05-12 10:08:35 +00:00
2012-03-16 13:00:05 +00:00
check mirror $vg $lv1 " $dev3 "
2010-05-12 10:08:35 +00:00
check mirror_no_temporaries $vg $lv1
check mirror_legs $vg $lv1 3
2012-03-04 16:02:19 +00:00
lvremove -ff $vg
2010-05-12 10:08:35 +00:00
# "remove from original mirror (the original becomes linear)"
2013-08-07 15:48:31 -05:00
lvcreate -aey -l2 --type mirror -m1 -n $lv1 $vg " $dev1 " " $dev2 " " $dev3 : $DEVRANGE "
2015-04-28 15:31:47 +02:00
LVM_TEST_TAG = " kill_me_ $PREFIX " lvconvert -m+1 -b $vg /$lv1 " $dev4 "
2014-05-19 14:30:15 +02:00
# FIXME: Extra wait here for mirror upconvert synchronization
# otherwise we may fail her on parallel upconvert and downconvert
# lvconvert-mirror-updown.sh tests this errornous case separately
lvconvert $vg /$lv1
2012-03-16 13:00:05 +00:00
lvconvert -m-1 $vg /$lv1 " $dev2 "
lvconvert $vg /$lv1
2010-05-12 10:08:35 +00:00
2012-03-16 13:00:05 +00:00
check mirror $vg $lv1 " $dev3 "
2010-05-12 10:08:35 +00:00
check mirror_no_temporaries $vg $lv1
check mirror_legs $vg $lv1 2
2012-03-04 16:02:19 +00:00
lvremove -ff $vg
2010-05-12 10:08:35 +00:00
# ---------------------------------------------------------------------
# "rhbz440405: lvconvert -m0 incorrectly fails if all PEs allocated"
2013-08-07 15:48:31 -05:00
lvcreate -aey -l$( pvs --noheadings -ope_count " $dev1 " ) --type mirror -m1 -n $lv1 $vg " $dev1 " " $dev2 " " $dev3 : $DEVRANGE "
2012-07-24 14:20:30 -05:00
aux wait_for_sync $vg $lv1
2012-03-16 13:00:05 +00:00
lvconvert -m0 $vg /$lv1 " $dev1 "
2010-05-12 10:08:35 +00:00
check linear $vg $lv1
2012-03-04 16:02:19 +00:00
lvremove -ff $vg
2010-05-12 10:08:35 +00:00
2013-09-25 22:25:43 -05:00
# "rhbz264241: lvm mirror doesn't lose it's "M" --nosync attribute
# after being down and the up converted"
2013-08-07 15:48:31 -05:00
lvcreate -aey -l2 --type mirror -m1 -n $lv1 --nosync $vg
2010-05-12 10:08:35 +00:00
lvconvert -m0 $vg /$lv1
2013-09-25 22:25:43 -05:00
lvconvert --type mirror -m1 $vg /$lv1
lvs --noheadings -o attr $vg /$lv1 | grep '^[[:space:]]*m'
2012-03-04 16:02:19 +00:00
lvremove -ff $vg
2010-05-12 10:08:35 +00:00
# lvconvert from linear (on multiple PVs) to mirror
2013-05-31 21:11:51 +02:00
lvcreate -aey -l 8 -n $lv1 $vg " $dev1 :0-3 " " $dev2 :0-3 "
2013-09-25 22:25:43 -05:00
lvconvert --type mirror -m1 $vg /$lv1
2010-05-12 10:08:35 +00:00
should check mirror $vg $lv1
check mirror_legs $vg $lv1 2
2012-03-04 16:02:19 +00:00
lvremove -ff $vg
2010-05-12 10:08:35 +00:00
# BZ 463272: disk log mirror convert option is lost if downconvert option is also given
2013-08-07 15:48:31 -05:00
lvcreate -aey -l1 --type mirror -m2 --corelog -n $lv1 $vg " $dev1 " " $dev2 " " $dev3 "
2012-07-24 14:20:30 -05:00
aux wait_for_sync $vg $lv1
2013-09-25 22:25:43 -05:00
lvconvert --type mirror -m1 --mirrorlog disk $vg /$lv1
2010-11-30 11:35:32 +00:00
check mirror $vg $lv1
not check mirror $vg $lv1 core
2012-03-04 16:02:19 +00:00
lvremove -ff $vg
2010-05-12 10:08:35 +00:00
# ---
# add mirror and disk log
2012-03-16 13:00:05 +00:00
# "add 1 mirror and disk log"
2013-08-07 15:48:31 -05:00
lvcreate -aey -l2 --type mirror -m1 --mirrorlog core -n $lv1 $vg " $dev1 " " $dev2 "
2010-05-12 10:08:35 +00:00
# FIXME on next line, specifying $dev3:0 $dev4 (i.e log device first) fails (!)
2013-05-31 21:11:51 +02:00
lvconvert -m+1 --mirrorlog disk -i1 $vg /$lv1 " $dev4 " " $dev3 : $DEVRANGE "
2010-05-12 10:08:35 +00:00
2012-03-16 13:00:05 +00:00
check mirror $vg $lv1 " $dev3 "
2010-05-12 10:08:35 +00:00
check mirror_no_temporaries $vg $lv1
check mirror_legs $vg $lv1 3
2012-03-04 16:02:19 +00:00
lvremove -ff $vg
2011-06-09 19:38:56 +00:00
# simple mirrored stripe
2013-05-31 21:11:51 +02:00
lvcreate -aey -i2 -l10 -n $lv1 $vg
2013-09-25 22:25:43 -05:00
lvconvert --type mirror -m1 -i1 $vg /$lv1
2011-06-09 19:38:56 +00:00
lvreduce -f -l1 $vg /$lv1
lvextend -f -l10 $vg /$lv1
lvremove -ff $vg /$lv1
2011-06-23 10:53:24 +00:00
# extents must be divisible
2013-05-31 21:11:51 +02:00
lvcreate -aey -l15 -n $lv1 $vg
2013-09-25 22:25:43 -05:00
not lvconvert --type mirror -m1 --corelog --stripes 2 $vg /$lv1
2012-03-04 16:02:19 +00:00
lvremove -ff $vg
2012-09-19 11:09:32 -05:00
2013-05-31 21:11:51 +02:00
test -e LOCAL_CLVMD && exit 0
# FIXME - cases which needs to be fixed to work in cluster
# Linear to mirror with mirrored log using --alloc anywhere
lvcreate -aey -l2 -n $lv1 $vg " $dev1 "
2013-09-25 22:25:43 -05:00
lvconvert --type mirror -m +1 --mirrorlog mirrored --alloc anywhere $vg /$lv1 " $dev1 " " $dev2 "
2013-05-31 21:11:51 +02:00
should check mirror $vg $lv1
lvremove -ff $vg
2012-09-19 11:09:32 -05:00
# Should not be able to add images to --nosync mirror
# but should be able to after 'lvchange --resync'
2013-08-07 15:48:31 -05:00
lvcreate -aey --type mirror -m 1 -l1 -n $lv1 $vg --nosync
2012-09-19 11:09:32 -05:00
not lvconvert -m +1 $vg /$lv1
2013-05-31 21:11:51 +02:00
lvchange -aey --resync -y $vg /$lv1
2012-09-19 11:09:32 -05:00
lvconvert -m +1 $vg /$lv1
lvremove -ff $vg
2013-08-07 15:48:31 -05:00
lvcreate -aey --type mirror -m 1 --corelog -l1 -n $lv1 $vg --nosync
2012-09-19 11:09:32 -05:00
not lvconvert -m +1 $vg /$lv1
2013-05-31 21:11:51 +02:00
lvchange -aey --resync -y $vg /$lv1
2012-09-19 11:09:32 -05:00
lvconvert -m +1 $vg /$lv1
lvremove -ff $vg
2013-05-31 21:11:51 +02:00
# FIXME: Cluster exclusive activation does not work here
# unsure why lib/metadata/mirror.c
# has this code:
#
# } else if (vg_is_clustered(vg)) {
# log_error("Unable to convert the log of an inactive "
# "cluster mirror, %s", lv->name);
# return 0;
# disabling this in the code passes this test
# bz192865: lvconvert log of an inactive mirror lv
# convert from disklog to corelog, inactive
2013-08-07 15:48:31 -05:00
lvcreate -aey -l2 --type mirror -m1 -n $lv1 $vg " $dev1 " " $dev2 " " $dev3 :0-1 "
2013-05-31 21:11:51 +02:00
lvchange -an $vg /$lv1
lvconvert -y -f --mirrorlog core $vg /$lv1
check mirror $vg $lv1 core
lvremove -ff $vg
# convert from corelog to disklog, inactive
2013-08-07 15:48:31 -05:00
lvcreate -aey -l2 --type mirror -m1 --mirrorlog core -n $lv1 $vg " $dev1 " " $dev2 "
2013-05-31 21:11:51 +02:00
lvchange -an $vg /$lv1
lvconvert --mirrorlog disk $vg /$lv1 " $dev3 :0-1 "
check mirror $vg $lv1 " $dev3 "
lvremove -ff $vg
2014-02-26 23:25:30 +01:00
vgremove -ff $vg