3
# Copyright (C) 2011-2012 Red Hat, Inc. All rights reserved.
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 currently needs to drop
14
# 'return NULL' in _lv_create_an_lv after log_error("Can't create %s without using "
21
check lv_exists $vg $d
25
check_lv_field_modules_()
31
check lv_field $vg/$d modules $mod
39
aux target_at_least dm-thin-pool 1 0 0 || skip
43
# disable thin_check if not present in system
44
which thin_check || aux lvmconf 'global/thin_check_executable = ""'
47
test -e LOCAL_CLVMD && clustered="--clustered y"
49
vgcreate $clustered $vg -s 64K $(cat DEVICES)
51
# Create named pool only
52
lvcreate -l1 -T $vg/pool1
53
lvcreate -l1 -T --thinpool $vg/pool2
54
lvcreate -l1 -T --thinpool pool3 $vg
55
lvcreate -l1 --type thin $vg/pool4
56
lvcreate -l1 --type thin --thinpool $vg/pool5
57
lvcreate -l1 --type thin --thinpool pool6 $vg
58
lvcreate -l1 --type thin-pool $vg/pool7
59
lvcreate -l1 --type thin-pool --thinpool $vg/pool8
60
lvcreate -l1 --type thin-pool --thinpool pool9 $vg
62
lvremove -ff $vg/pool1 $vg/pool2 $vg/pool3 $vg/pool4 $vg/pool5 $vg/pool6 $vg/pool7 $vg/pool8 $vg/pool9
63
check vg_field $vg lv_count 0
66
# Create default pool name
68
lvcreate -l1 --type thin $vg
69
lvcreate -l1 --type thin-pool $vg
71
lvremove -ff $vg/lvol0 $vg/lvol1 $vg/lvol2
72
check vg_field $vg lv_count 0
75
# Create default pool and default thin LV
76
lvcreate -l1 -V2G -T $vg
77
lvcreate -l1 -V2G --type thin $vg
82
# Create named pool and default thin LV
83
lvcreate -L4M -V2G -T $vg/pool1
84
lvcreate -L4M -V2G -T --thinpool $vg/pool2
85
lvcreate -L4M -V2G -T --thinpool pool3 $vg
86
lvcreate -L4M -V2G --type thin $vg/pool4
87
lvcreate -L4M -V2G --type thin --thinpool $vg/pool5
88
lvcreate -L4M -V2G --type thin --thinpool pool6 $vg
90
check_lv_exists_ lvol0 lvol1 lvol2 lvol3 lvol4 lvol5
94
# Create named pool and named thin LV
95
lvcreate -L4M -V2G -T $vg/pool1 --name lv1
96
lvcreate -L4M -V2G -T $vg/pool2 --name $vg/lv2
97
lvcreate -L4M -V2G -T --thinpool $vg/pool3 --name lv3
98
lvcreate -L4M -V2G -T --thinpool $vg/pool4 --name $vg/lv4
99
lvcreate -L4M -V2G -T --thinpool pool5 --name lv5 $vg
100
lvcreate -L4M -V2G -T --thinpool pool6 --name $vg/lv6 $vg
102
check_lv_exists_ lv1 lv2 lv3 lv4 lv5 lv6
106
lvcreate -L4M -V2G --type thin $vg/pool1 --name lv1
107
lvcreate -L4M -V2G --type thin $vg/pool2 --name $vg/lv2
108
lvcreate -L4M -V2G --type thin --thinpool $vg/pool3 --name lv3
109
lvcreate -L4M -V2G --type thin --thinpool $vg/pool4 --name $vg/lv4
110
lvcreate -L4M -V2G --type thin --thinpool pool5 --name lv5 $vg
111
lvcreate -L4M -V2G --type thin --thinpool pool6 --name $vg/lv6 $vg
113
check_lv_exists_ lv1 lv2 lv3 lv4 lv5 lv6
117
# Create default thin LV in existing pool
118
lvcreate -L4M -T $vg/pool
119
lvcreate -V2G -T $vg/pool
120
lvcreate -V2G -T --thinpool $vg/pool
121
lvcreate -V2G -T --thinpool pool $vg
122
lvcreate -V2G --type thin $vg/pool
123
lvcreate -V2G --type thin --thinpool $vg/pool
124
lvcreate -V2G --type thin --thinpool pool $vg
126
check_lv_exists_ lvol0 lvol1 lvol2 lvol3 lvol4 lvol5
129
# Create named thin LV in existing pool
130
lvcreate -V2G -T $vg/pool --name lv1
131
lvcreate -V2G -T $vg/pool --name $vg/lv2
132
lvcreate -V2G -T --thinpool $vg/pool --name lv3
133
lvcreate -V2G -T --thinpool $vg/pool --name $vg/lv4
134
lvcreate -V2G -T --thinpool pool --name lv5 $vg
135
lvcreate -V2G -T --thinpool pool --name $vg/lv6 $vg
136
lvcreate -V2G --type thin $vg/pool --name lv7
137
lvcreate -V2G --type thin $vg/pool --name $vg/lv8
138
lvcreate -V2G --type thin --thinpool $vg/pool --name lv9
139
lvcreate -V2G --type thin --thinpool $vg/pool --name $vg/lv10
140
lvcreate -V2G --type thin --thinpool pool --name lv11 $vg
141
lvcreate -V2G --type thin --thinpool pool --name $vg/lv12 $vg
143
check_lv_exists_ lv1 lv2 lv3 lv4 lv5 lv6 lv7 lv8 lv9 lv10 lv11 lv12
144
check vg_field $vg lv_count 19
147
check vg_field $vg lv_count 0
149
# Create thin snapshot of thinLV
150
lvcreate -L10M -V10M -T $vg/pool --name lv1
151
mkfs.ext4 $DM_DEV_DIR/$vg/lv1
153
fsck -p $DM_DEV_DIR/$vg/lvol0
154
lvcreate -s $vg/lv1 --name lv2
155
lvcreate -s $vg/lv1 --name $vg/lv3
156
lvcreate --type snapshot $vg/lv1
157
lvcreate --type snapshot $vg/lv1 --name lv4
158
lvcreate --type snapshot $vg/lv1 --name $vg/lv5
160
check_lv_field_modules_ thin-pool lv1 lvol0 lv2 lv3 lvol1 lv4 lv5
161
check vg_field $vg lv_count 8
165
# Normal Snapshots of thinLV
166
lvcreate -L4M -V2G -T $vg/pool --name lv1
167
lvcreate -s $vg/lv1 -l1
168
lvcreate -s $vg/lv1 -l1 --name lv2
169
lvcreate -s $vg/lv1 -l1 --name $vg/lv3
170
lvcreate -s lv1 -L4M --name $vg/lv4
172
check_lv_field_modules_ snapshot lvol0 lv2 lv3 lv4
173
check vg_field $vg lv_count 6
176
check vg_field $vg lv_count 0
180
# Too small pool size (1 extent 64KB) for given chunk size
181
not lvcreate --chunksize 256 -l1 -T $vg/pool1
182
# Too small chunk size (min is 64KB - 128 sectors)
183
not lvcreate --chunksize 32 -l1 -T $vg/pool1
185
lvcreate -L4M -V2G --name lv1 -T $vg/pool1
186
# Origin name is not accepted
187
not lvcreate -s $vg/lv1 -L4M -V2G --name $vg/lv4
191
# Test --poolmetadatasize
192
# allocating large devices for testing
194
aux prepare_pvs 7 16500
195
vgcreate $clustered $vg -s 64K $(cat DEVICES)
197
lvcreate -L4M --chunksize 128 -T $vg/pool
198
lvcreate -L4M --chunksize 128 --poolmetadatasize 0 -T $vg/pool1 2>out
199
grep "WARNING: Minimum" out
200
# FIXME: metadata allocation fails, if PV doesn't have at least 16GB
201
# i.e. pool metadata device cannot be multisegment
202
lvcreate -L4M --chunksize 128 --poolmetadatasize 17G -T $vg/pool2 2>out
203
grep "WARNING: Maximum" out
204
check lv_field $vg/pool_tmeta size "2.00m"
205
check lv_field $vg/pool1_tmeta size "2.00m"
206
check lv_field $vg/pool2_tmeta size "16.00g"
209
# check automatic calculation of poolmetadatasize
210
lvcreate -L10G --chunksize 128 -T $vg/pool
211
lvcreate -L10G --chunksize 256 -T $vg/pool1
212
lvcreate -L60G --chunksize 1024 -T $vg/pool2
213
check lv_field $vg/pool_tmeta size "5.00m"
214
check lv_field $vg/pool1_tmeta size "2.50m"
215
check lv_field $vg/pool2_tmeta size "3.75m"