2 # Copyright (C) 2007-2008 Red Hat, Inc. All rights reserved.
3 # Copyright (C) 2007-2008 NEC Corporation
5 # This copyrighted material is made available to anyone wishing to use,
6 # modify, copy, or redistribute it subject to the terms and conditions
7 # of the GNU General Public License v.2.
9 # You should have received a copy of the GNU General Public License
10 # along with this program; if not, write to the Free Software Foundation,
11 # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
13 test_description="check namings of mirrored LV"
17 # ---------------------------------------------------------------------
26 local devs=$(lvs -a -odevices --noheadings $lv | sed 's/([0-9]*)//g' |
27 sed 's/ //g' | sed 's/,/ /g')
30 (echo $devices | grep -q $d) || return 1
31 devices=$(echo $devices | sed "s/$d//")
34 [ "$(echo $devices | sed 's/ //g')" = "" ]
40 echo $(lvs -a -omirror_log --noheadings $lv | sed 's/ //g')
46 echo $(lvs -a -oconvert_lv --noheadings $lv | sed 's/ //g')
49 # ---------------------------------------------------------------------
50 # Initialize PVs and VGs
54 # ---------------------------------------------------------------------
55 # Common environment setup/cleanup for each sub testcases
59 if dmsetup table|grep $vg; then
60 echo "ERROR: lvremove did leave some some mappings in DM behind!"
66 check_and_cleanup_lvs_() {
69 if dmsetup table|grep $vg; then
70 echo "ERROR: lvremove did leave some some mappings in DM behind!"
76 check_and_cleanup_lvs_
78 # ---------------------------------------------------------------------
81 #COMM "init: lvcreate"
84 #COMM "mirror images are ${lv1}_mimage_x"
85 lvcreate -l2 -m1 -n $lv1 $vg
86 lv_devices_ $vg/$lv1 "$lv1"_mimage_0 "$lv1"_mimage_1
88 #COMM "mirror log is ${lv1}_mlog"
89 lv_mirror_log_ $vg/$lv1 "$lv1"_mlog
92 check_and_cleanup_lvs_
94 #COMM "mirror with name longer than 22 characters (bz221322)"
95 name="LVwithanamelogerthan22characters_butidontwonttocounthem"
96 lvcreate -m1 -l2 -n"$name" $vg
98 check_and_cleanup_lvs_
100 # ---------------------------------------------------------------------
103 #COMM "init: lvrename"
106 #COMM "renamed mirror names: $lv1 to $lv2"
107 lvcreate -l2 -m1 -n $lv1 $vg
108 lvrename $vg/$lv1 $vg/$lv2
109 lv_devices_ $vg/$lv2 "$lv2"_mimage_0 "$lv2"_mimage_1
110 lv_mirror_log_ $vg/$lv2 "$lv2"_mlog
113 check_and_cleanup_lvs_
115 # ---------------------------------------------------------------------
118 #COMM "init: lvconvert"
121 #COMM "converting mirror names is ${lv1}_mimagetmp_2"
122 lvcreate -l2 -m1 -n $lv1 $vg
123 lvconvert -m+1 -i+10 -b $vg/$lv1
124 convlv=$(lv_convert_lv_ "$vg/$lv1")
125 test "$convlv" = "$lv1"_mimagetmp_2
126 lv_devices_ $vg/$lv1 "$convlv" "$lv1"_mimage_2
127 lv_devices_ "$vg/$convlv" "$lv1"_mimage_0 "$lv1"_mimage_1
128 loglv=$(lv_mirror_log_ "$vg/$convlv")
129 test "$loglv" = "$lv1"_mlog
131 #COMM "mirror log name after re-adding is ${lv1}_mlog" \
132 lvconvert --mirrorlog core $vg/$lv1
133 lvconvert --mirrorlog disk $vg/$lv1
134 convlv=$(lv_convert_lv_ "$vg/$lv1")
135 lv_devices_ $vg/$lv1 "$convlv" "$lv1"_mimage_2
136 lv_devices_ "$vg/$convlv" "$lv1"_mimage_0 "$lv1"_mimage_1
137 loglv=$(lv_mirror_log_ "$vg/$convlv")
138 test "$loglv" = "$lv1"_mlog
140 #COMM "renamed converting mirror names: $lv1 to $lv2" \
141 lvrename $vg/$lv1 $vg/$lv2
142 convlv=$(lv_convert_lv_ "$vg/$lv2")
143 lv_devices_ $vg/$lv2 "$convlv" "$lv2"_mimage_2
144 lv_devices_ "$vg/$convlv" "$lv2"_mimage_0 "$lv2"_mimage_1
145 loglv=$(lv_mirror_log_ "$vg/$convlv")
146 test "$loglv" = "$lv2"_mlog
149 check_and_cleanup_lvs_
151 # Temporary mirror log should have "_mlogtmp_<n>" suffix
152 # but currently lvconvert doesn't have an option to add the log.
153 # If such feature is added in future, a test for that should
156 # ---------------------------------------------------------------------