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

# Copyright (C) 2018 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 activation of cache component devices


SKIP_WITH_LVMPOLLD=1

. lib/inittest

aux have_cache 1 3 0 || skip

aux prepare_vg 5 80

lvcreate --type cache-pool -L 2 -n cpool $vg
lvcreate -H -L 4 -n corigin --cachepool $vg/cpool
lvchange -an $vg

for j in 1 2
do

# Activate supported components
for i in cpool_cpool_cmeta cpool_cpool_cdata corigin_corig
do
	test ! -e "$DM_DEV_DIR/$vg/$i"
	lvchange -ay -y $vg/$i
	# check usable link is there
	test -e "$DM_DEV_DIR/$vg/$i"

        # cannot take snapshot of any active component LV
        test "$j" -eq 2 || not lvcreate -s -L1 $vg/$i
done

# After 1st. phase deactivation works
# Volumes are left active for vgremove on 2nd.. pass
test "$j" -eq 2 || lvchange -an $vg

done

# Cannot active cached LV while any component LV is active
not lvchange -ay $vg/corigin |& tee err
grep "prohibited" err

lvs -a $vg

# Can split for writethrough|passthrough
# deactivates all components as well...
lvconvert --splitcache $vg/corigin
lvs -a $vg

# Cannot cache LV while components are active
lvcreate -L 4 -n $lv2 $vg
lvchange -ay -y $vg/cpool_cmeta

not lvconvert -y --cachepool $vg/cpool -H $lv2

lvremove -f $vg
lvs -a $vg

if aux have_thin 1 0 0 ; then

lvcreate --type cache-pool -L 2 -n cpool $vg
lvcreate -H -L 4 -n tpool --cachepool $vg/cpool
lvchange -an $vg
lvs -a $vg
# Cannot convert to thin-pool with component LV active
lvchange -ay -y $vg/cpool_cpool_cmeta

# Conversion does not need to activate data device, so it can proceed ??
lvconvert -y --thinpool $vg/tpool

# Thin-pool cannot be activated
not lvchange -ay $vg/tpool |& tee err
grep "prohibited" err

lvs -a $vg

fi

lvs -a $vg

# And final removal works
vgremove -f $vg