summaryrefslogtreecommitdiff
path: root/test/shell/cache-metadata2.sh
blob: 0270f5d715f5df4c30f6b52b31497c582b6ceb29 (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
#!/usr/bin/env bash

# Copyright (C) 2017 Red Hat, Inc. All rights reserved.
#
# 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

# Exercise usage of metadata2 cache metadata format


SKIP_WITH_LVMPOLLD=1

# Until new version of cache_check tools - no integrity validation
LVM_TEST_CACHE_CHECK_CMD=""

. lib/inittest

META2=
aux have_cache 1 10 0 || {
	META2=not
	aux have_cache 1 3 0 || skip
}

aux prepare_vg 5 80

lvcreate -L2 -n $lv1 $vg

lvcreate --type cache-pool -L1 $vg/cpool1
# no parameter - no format is stored
check lv_field $vg/cpool1 cachemetadataformat ""

lvcreate --type cache-pool -L1 --config 'allocation/cache_metadata_format=1' $vg/cpool
# format is in configuration - would be applied during actual caching
# so not stored in this moment
check lv_field $vg/cpool cachemetadataformat ""


lvcreate --type cache-pool -L1 --cachemetadataformat 1 $vg/cpool2
# format was specified on cmdline  - preserve it metadata
check lv_field $vg/cpool2 cachemetadataformat "1"

lvconvert --yes -H --cachepool $vg/cpool --config 'allocation/cache_metadata_format=1' $vg/$lv1
check lv_field $vg/cpool2 cachemetadataformat "1"

lvs -a -o+cachemetadataformat $vg

lvremove -f $vg

lvcreate --type cache-pool --cachepolicy cleaner --cachemetadataformat 1 -L1 $vg/cpool
lvcreate -H -L10 -n $lv1 --cachepool $vg/cpool
check lv_field $vg/$lv1 cachemetadataformat "1"
lvremove -f $vg

if [ -z "$META2" ]; then
# for these test we need kernel with metadata2 support

lvcreate --type cache-pool -L1 $vg/cpool
lvcreate -H -L10 -n $lv1 --cachepool $vg/cpool
check lv_field $vg/$lv1 cachemetadataformat "2"
lvremove -f $vg

lvcreate -L10 -n $lv1 $vg
lvcreate --type cache-pool -L1 $vg/cpool
lvconvert -y -H --cachepool $vg/cpool $vg/$lv1
check lv_field $vg/$lv1 cachemetadataformat "2"
lvremove -f $vg


lvcreate -L10 -n $lv1 $vg
lvcreate --type cache-pool -L1 $vg/cpool
lvconvert --cachemetadataformat 1 -y -H --cachepool $vg/cpool $vg/$lv1
check lv_field $vg/$lv1 cachemetadataformat "1"
lvremove -f $vg

lvcreate -L10 -n $lv1 $vg
lvcreate --type cache-pool -L1 $vg/cpool
lvconvert --config 'allocation/cache_metadata_format=1' -y -H --cachepool $vg/cpool $vg/$lv1
check lv_field $vg/$lv1 cachemetadataformat "1"
lvremove -f $vg

lvcreate --type cache-pool --cachepolicy cleaner -L1 $vg/cpool
lvcreate -H -L10 -n $lv1 --cachepool $vg/cpool
check lv_field $vg/$lv1 cachemetadataformat "2"
lvremove -f $vg

lvcreate --type cache-pool --cachepolicy mq --cachemetadataformat 1 -L1 $vg/cpool
check lv_field $vg/cpool cachemetadataformat "1"
lvcreate -H -L10 -n $lv1 --cachemetadataformat 2 --cachepool $vg/cpool
check lv_field $vg/$lv1 cachemetadataformat "2"
lvremove -f $vg

fi
#lvs -a -o name,cachemetadataformat,kernelmetadataformat,chunksize,cachepolicy,cachemode $vg

vgremove -f $vg