1.2.13
by Bastian Blank
Import upstream version 2.02.98 |
1 |
#!/bin/sh
|
2 |
# Copyright (C) 2010-2012 Red Hat, Inc. All rights reserved.
|
|
1.2.12
by Bastian Blank
Import upstream version 2.02.95 |
3 |
#
|
4 |
# This copyrighted material is made available to anyone wishing to use,
|
|
5 |
# modify, copy, or redistribute it subject to the terms and conditions
|
|
6 |
# of the GNU General Public License v.2.
|
|
7 |
#
|
|
8 |
# You should have received a copy of the GNU General Public License
|
|
9 |
# along with this program; if not, write to the Free Software Foundation,
|
|
10 |
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
11 |
||
12 |
. lib/test |
|
13 |
||
1.2.13
by Bastian Blank
Import upstream version 2.02.98 |
14 |
log_name_to_count() { |
15 |
case "$1" in |
|
16 |
mirrored) echo 2 ;; |
|
17 |
disk) echo 1 ;; |
|
18 |
*) echo 0 ;; |
|
19 |
esac
|
|
1.2.12
by Bastian Blank
Import upstream version 2.02.95 |
20 |
}
|
21 |
||
22 |
# FIXME: For test_[up|down]convert, I'd still like to be able
|
|
23 |
# to specifiy devices - especially if I can do partial PV
|
|
24 |
# specification for down-converts. It may even be wise to
|
|
25 |
# do one round through these tests without specifying the PVs
|
|
26 |
# to use and one round where we do.
|
|
27 |
||
28 |
# test_lvconvert
|
|
29 |
# start_mirror_count: The '-m' argument to create with
|
|
30 |
# start_log_type: core|disk|mirrored
|
|
31 |
# final_mirror_count: The '-m' argument to convert to
|
|
32 |
# final_log_type: core|disk|mirrored
|
|
33 |
# active: Whether the LV should be active when the convert happens
|
|
34 |
#
|
|
35 |
# Exmaple: Convert 3-way disk-log mirror to
|
|
36 |
# 2-way disk-log mirror while not active
|
|
37 |
# -> test_lvconvert 2 disk 3 disk 0
|
|
38 |
||
1.2.13
by Bastian Blank
Import upstream version 2.02.98 |
39 |
test_lvconvert() { |
1.2.12
by Bastian Blank
Import upstream version 2.02.95 |
40 |
local start_count=$1 |
41 |
local start_count_p1=$(($start_count + 1)) |
|
42 |
local start_log_type=$2 |
|
43 |
local finish_count=$3 |
|
44 |
local finish_count_p1=$(($finish_count + 1)) |
|
45 |
local finish_log_type=$4 |
|
1.2.13
by Bastian Blank
Import upstream version 2.02.98 |
46 |
local dev_array=("$dev1" "$dev2" "$dev3" "$dev4" "$dev5") |
1.2.12
by Bastian Blank
Import upstream version 2.02.95 |
47 |
local start_log_count
|
48 |
local finish_log_count
|
|
49 |
local max_log_count
|
|
50 |
local alloc="" |
|
51 |
local active=true |
|
52 |
local i
|
|
53 |
||
54 |
test "$5" = "active" && active=false |
|
55 |
#test $finish_count -gt $start_count && up=true
|
|
56 |
||
57 |
# Do we have enough devices for the mirror images?
|
|
1.2.13
by Bastian Blank
Import upstream version 2.02.98 |
58 |
test $start_count_p1 -gt ${#dev_array[@]} && \ |
59 |
die "Action requires too many devices"
|
|
1.2.12
by Bastian Blank
Import upstream version 2.02.95 |
60 |
|
61 |
# Do we have enough devices for the mirror images?
|
|
1.2.13
by Bastian Blank
Import upstream version 2.02.98 |
62 |
test $finish_count_p1 -gt ${#dev_array[@]} && \ |
63 |
die "Action requires too many devices"
|
|
1.2.12
by Bastian Blank
Import upstream version 2.02.95 |
64 |
|
1.2.13
by Bastian Blank
Import upstream version 2.02.98 |
65 |
start_log_count=$(log_name_to_count $start_log_type) |
66 |
finish_log_count=$(log_name_to_count $finish_log_type) |
|
1.2.12
by Bastian Blank
Import upstream version 2.02.95 |
67 |
if [ $finish_log_count -gt $start_log_count ]; then |
68 |
max_log_count=$finish_log_count |
|
69 |
else
|
|
70 |
max_log_count=$start_log_count |
|
71 |
fi
|
|
72 |
||
73 |
if [ $start_count -gt 0 ]; then |
|
74 |
# Are there extra devices for the log or do we overlap
|
|
75 |
if [ $(($start_count_p1 + $start_log_count)) -gt ${#dev_array[@]} ]; then |
|
76 |
alloc="--alloc anywhere" |
|
77 |
fi
|
|
78 |
||
79 |
lvcreate -l2 -m $start_count --mirrorlog $start_log_type \ |
|
80 |
-n $lv1 $vg $alloc |
|
81 |
check mirror_legs $vg $lv1 $start_count_p1 |
|
82 |
# FIXME: check mirror log
|
|
83 |
else
|
|
84 |
lvcreate -l2 -n $lv1 $vg |
|
85 |
fi
|
|
86 |
||
87 |
lvs -a -o name,copy_percent,devices $vg
|
|
1.2.13
by Bastian Blank
Import upstream version 2.02.98 |
88 |
test $active || lvchange -an $vg/$lv1 |
1.2.12
by Bastian Blank
Import upstream version 2.02.95 |
89 |
|
90 |
# Are there extra devices for the log or do we overlap
|
|
91 |
if [ $(($finish_count_p1 + $finish_log_count)) -gt ${#dev_array[@]} ]; then |
|
92 |
alloc="--alloc anywhere" |
|
93 |
fi
|
|
94 |
||
95 |
lvconvert -m $finish_count --mirrorlog $finish_log_type \ |
|
96 |
$vg/$lv1 $alloc |
|
97 |
||
1.2.13
by Bastian Blank
Import upstream version 2.02.98 |
98 |
test $active || lvchange -ay $vg/$lv1 |
1.2.12
by Bastian Blank
Import upstream version 2.02.95 |
99 |
|
100 |
check mirror_no_temporaries $vg $lv1 |
|
101 |
if [ "$finish_count_p1" -eq 1 ]; then |
|
102 |
check linear $vg $lv1 |
|
103 |
else
|
|
104 |
if test -n "$alloc"; then |
|
105 |
check mirror_nonredundant $vg $lv1 |
|
106 |
else
|
|
107 |
check mirror $vg $lv1 |
|
108 |
fi
|
|
109 |
check mirror_legs $vg $lv1 $finish_count_p1 |
|
110 |
fi
|
|
111 |
}
|
|
112 |
||
113 |
aux prepare_pvs 5 5 |
|
114 |
vgcreate -c n -s 128k $vg $(cat DEVICES) |
|
115 |
||
116 |
test_many() { |
|
117 |
i=$1 |
|
118 |
for j in $(seq 0 3); do |
|
119 |
for k in core disk mirrored; do |
|
120 |
for l in core disk mirrored; do |
|
121 |
if test "$i" -eq "$j" && test "$k" = "$l"; then continue; fi |
|
122 |
: ---------------------------------------------------- |
|
123 |
: "Testing mirror conversion -m$i/$k -> -m$j/$l" |
|
124 |
: ---------------------------------------------------- |
|
125 |
test_lvconvert $i $k $j $l 0 |
|
126 |
lvremove -ff $vg
|
|
127 |
test_lvconvert $i $k $j $l 1 |
|
128 |
lvremove -ff $vg
|
|
129 |
done
|
|
130 |
done
|
|
131 |
done
|
|
132 |
}
|