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 dmsetup_has_dm_devdir_support_ ||
exit 200
19 # ---------------------------------------------------------------------
28 local devs
=$
(lvs
-a -odevices --noheadings $lv |
sed 's/([0-9]*)//g' |
29 sed 's/ //g' |
sed 's/,/ /g')
32 (echo $devices |
grep -q $d) ||
return 1
33 devices
=$
(echo $devices |
sed "s/$d//")
36 [ "$(echo $devices | sed 's/ //g')" = "" ]
42 echo $
(lvs
-a -omirror_log --noheadings $lv |
sed 's/ //g')
48 echo $
(lvs
-a -oconvert_lv --noheadings $lv |
sed 's/ //g')
51 # ---------------------------------------------------------------------
52 # Initialize PVs and VGs
56 # ---------------------------------------------------------------------
57 # Common environment setup/cleanup for each sub testcases
61 if dmsetup table|
grep $vg; then
62 echo "ERROR: lvremove did leave some some mappings in DM behind!"
68 check_and_cleanup_lvs_
() {
71 if dmsetup table|
grep $vg; then
72 echo "ERROR: lvremove did leave some some mappings in DM behind!"
78 check_and_cleanup_lvs_
80 # ---------------------------------------------------------------------
83 #COMM "init: lvcreate"
86 #COMM "mirror images are ${lv1}_mimage_x"
87 lvcreate
-l2 -m1 -n $lv1 $vg
88 lv_devices_
$vg/$lv1 "$lv1"_mimage_0
"$lv1"_mimage_1
90 #COMM "mirror log is ${lv1}_mlog"
91 lv_mirror_log_
$vg/$lv1 "$lv1"_mlog
94 check_and_cleanup_lvs_
96 #COMM "mirror with name longer than 22 characters (bz221322)"
97 name
="LVwithanamelogerthan22characters_butidontwonttocounthem"
98 lvcreate
-m1 -l2 -n"$name" $vg
100 check_and_cleanup_lvs_
102 # ---------------------------------------------------------------------
105 #COMM "init: lvrename"
108 #COMM "renamed mirror names: $lv1 to $lv2"
109 lvcreate
-l2 -m1 -n $lv1 $vg
110 lvrename
$vg/$lv1 $vg/$lv2
111 lv_devices_
$vg/$lv2 "$lv2"_mimage_0
"$lv2"_mimage_1
112 lv_mirror_log_
$vg/$lv2 "$lv2"_mlog
115 check_and_cleanup_lvs_
117 # ---------------------------------------------------------------------
120 #COMM "init: lvconvert"
123 #COMM "converting mirror names is ${lv1}_mimagetmp_2"
124 lvcreate
-l2 -m1 -n $lv1 $vg
125 lvconvert
-m+1 -i1000 -b $vg/$lv1
126 convlv
=$
(lv_convert_lv_
"$vg/$lv1")
127 test "$convlv" = "$lv1"_mimagetmp_2
128 lv_devices_
$vg/$lv1 "$convlv" "$lv1"_mimage_2
129 lv_devices_
"$vg/$convlv" "$lv1"_mimage_0
"$lv1"_mimage_1
130 loglv
=$
(lv_mirror_log_
"$vg/$convlv")
131 test "$loglv" = "$lv1"_mlog
133 #COMM "mirror log name after re-adding is ${lv1}_mlog" \
134 lvconvert
--mirrorlog core
$vg/$lv1
135 lvconvert
--mirrorlog disk
$vg/$lv1
136 convlv
=$
(lv_convert_lv_
"$vg/$lv1")
137 lv_devices_
$vg/$lv1 "$convlv" "$lv1"_mimage_2
138 lv_devices_
"$vg/$convlv" "$lv1"_mimage_0
"$lv1"_mimage_1
139 loglv
=$
(lv_mirror_log_
"$vg/$convlv")
140 test "$loglv" = "$lv1"_mlog
142 #COMM "renamed converting mirror names: $lv1 to $lv2" \
143 lvrename
$vg/$lv1 $vg/$lv2
144 convlv
=$
(lv_convert_lv_
"$vg/$lv2")
145 lv_devices_
$vg/$lv2 "$convlv" "$lv2"_mimage_2
146 lv_devices_
"$vg/$convlv" "$lv2"_mimage_0
"$lv2"_mimage_1
147 loglv
=$
(lv_mirror_log_
"$vg/$convlv")
148 test "$loglv" = "$lv2"_mlog
151 check_and_cleanup_lvs_
153 # Temporary mirror log should have "_mlogtmp_<n>" suffix
154 # but currently lvconvert doesn't have an option to add the log.
155 # If such feature is added in future, a test for that should
158 # ---------------------------------------------------------------------