blob: 8d525ca514067a7008ddfddad85602a3016549bf (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
|
#!/usr/bin/env bash
# Copyright (C) 2007-2017 Red Hat, Inc. All rights reserved.
# Copyright (C) 2007-2008 NEC Corporation
#
# 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
test_description="check namings of mirrored LV"
. lib/inittest
# ---------------------------------------------------------------------
# Utilities
lv_devices_() {
local d
local i
local lv=$1
shift
local devices=( "$@" )
local devs
devs=$(get lv_devices "$lv")
for d in $devs; do
(echo "${devices[@]}" | grep "$d") || return 1
for i in "${!devices[@]}"; do
if [ "${devices[i]}" = "$d" ] ; then
unset "devices[i]"
fi
done
done
test "${#devices[@]}" -eq 0 ||
die "Left devices " "${devices[@]}"
}
lv_mirror_log_() {
get lv_field "$1" mirror_log | tr -d '[]'
}
lv_convert_lv_() {
get lv_field "$1" convert_lv | tr -d '[]'
}
# ---------------------------------------------------------------------
# Common environment setup/cleanup for each sub testcases
check_and_cleanup_lvs_() {
lvs -a -o+devices $vg
lvremove -ff $vg
(dm_table | not grep $vg) || \
die "ERROR: lvremove did leave some some mappings in DM behind!"
}
# ---------------------------------------------------------------------
# Initialize PVs and VGs
aux prepare_vg 5 80
check_and_cleanup_lvs_
# ---------------------------------------------------------------------
# basic
#COMM "init: lvcreate"
#COMM "mirror images are ${lv1}_mimage_x"
lvcreate -an -Zn -l2 --type mirror -m1 -n $lv1 $vg
lv_devices_ $vg/$lv1 ${lv1}_mimage_0 ${lv1}_mimage_1
#COMM "mirror log is ${lv1}_mlog"
test "$(lv_mirror_log_ $vg/$lv1)" = "${lv1}_mlog"
# "cleanup"
check_and_cleanup_lvs_
#COMM "mirror with name longer than 22 characters (bz221322)"
name="LVwithanamelogerthan22characters_butidontwonttocounthem"
lvcreate -an -Zn --type mirror -m1 -l2 -n $name $vg
lvs $vg/$name
check_and_cleanup_lvs_
# ---------------------------------------------------------------------
# lvrename
#COMM "init: lvrename"
#COMM "renamed mirror names: $lv1 to $lv2"
lvcreate -an -Zn -l2 --type mirror -m1 -n $lv1 $vg
lvrename $vg/$lv1 $vg/$lv2
lv_devices_ $vg/$lv2 ${lv2}_mimage_0 ${lv2}_mimage_1
lv_mirror_log_ $vg/$lv2 ${lv2}_mlog
#COMM "cleanup"
check_and_cleanup_lvs_
# ---------------------------------------------------------------------
# lvconvert
#COMM "init: lvconvert"
#COMM "converting mirror names is ${lv1}_mimagetmp_2"
lvcreate -aey -l2 --type mirror -m1 -n $lv1 $vg
# Use large enough polling interval so mirror is keeping mimagetmp
LVM_TEST_TAG="kill_me_$PREFIX" lvconvert -m+1 -i+40 -b $vg/$lv1
#
# TODO: lvmpolld is not 'preserving' -i interval setting from
# lvconvert initiating command - so there is not much to test
# if the lvconvert is already finished at this point
# and lvmpolld cleaned metadata and refreshed DM table
#
# It' unclear if this is undocumented feature of bug.
#
if test ! -f LOCAL_LVMPOLLD ; then
for i in $(seq 1 10) ; do
# check if background process already started
# this is recognized by presence of LV1_mimage_2
check lvl $vg/${lv1}_mimage_2 && break
sleep .1
done
convlv=$(lv_convert_lv_ $vg/$lv1)
test "$convlv" = "${lv1}_mimagetmp_2"
lv_devices_ $vg/$lv1 $convlv ${lv1}_mimage_2
lv_devices_ $vg/$convlv ${lv1}_mimage_0 ${lv1}_mimage_1
lv_mirror_log_ $vg/$convlv ${lv1}_mlog
check lv_exists $vg ${lv1}_mimagetmp_2
#COMM "mirror log name after re-adding is ${lv1}_mlog"
lvconvert -f --mirrorlog core $vg/$lv1
lvconvert --mirrorlog disk $vg/$lv1
convlv=$(lv_convert_lv_ $vg/$lv1)
lv_devices_ $vg/$lv1 $convlv ${lv1}_mimage_2
lv_devices_ $vg/$convlv ${lv1}_mimage_0 ${lv1}_mimage_1
lv_mirror_log_ $vg/$convlv ${lv1}_mlog
#COMM "renamed converting mirror names: $lv1 to $lv2"
lvrename $vg/$lv1 $vg/$lv2
convlv=$(lv_convert_lv_ $vg/$lv2)
lv_devices_ $vg/$lv2 $convlv ${lv2}_mimage_2
lv_devices_ $vg/$convlv ${lv2}_mimage_0 ${lv2}_mimage_1
lv_mirror_log_ $vg/$convlv ${lv2}_mlog
fi # ! -f LOCAL_LVMPOLLD
#COMM "cleanup"
check_and_cleanup_lvs_
# Temporary mirror log should have "_mlogtmp_<n>" suffix
# but currently lvconvert doesn't have an option to add the log.
# If such feature is added in future, a test for that should
# be added.
# ---------------------------------------------------------------------
|