2017-07-02 22:38:32 +03:00
#!/usr/bin/env bash
2015-11-19 16:31:58 +03:00
# Copyright (C) 2014-2015 Red Hat, Inc. All rights reserved.
2014-10-07 12:12:39 +04:00
#
# 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,
2016-01-21 13:49:46 +03:00
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2014-10-07 12:12:39 +04:00
# Exercise usage of stacked cache volume using raid volume
2015-10-27 17:10:06 +03:00
SKIP_WITH_LVMPOLLD = 1
2014-10-07 12:12:39 +04:00
2015-10-27 17:10:06 +03:00
. lib/inittest
2015-05-09 02:59:18 +03:00
2014-10-07 12:12:39 +04:00
aux have_cache 1 3 0 || skip
aux have_raid 1 0 0 || skip
2015-08-12 15:18:28 +03:00
aux lvmconf 'global/cache_disabled_features = [ "policy_smq" ]'
2014-10-07 12:12:39 +04:00
aux prepare_vg 5 80
# Bug 1095843
# lvcreate RAID1 origin, lvcreate cache-pool, and lvconvert to cache
2015-09-10 16:07:59 +03:00
lvcreate --type raid1 -m 1 --nosync -l 2 -n $lv1 $vg
2014-10-07 12:12:39 +04:00
lvcreate --type cache-pool -l 1 -n ${ lv1 } _cachepool $vg
2016-07-23 22:18:30 +03:00
lvconvert --cache -Zy --cachepool $vg /${ lv1 } _cachepool $vg /$lv1
2014-10-07 12:12:39 +04:00
check lv_exists $vg /${ lv1 } _corig_rimage_0 # ensure images are properly renamed
dmsetup table ${ vg } -$lv1 | grep cache # ensure it is loaded in kernel
lvremove -f $vg
# lvcreate RAID1 origin, lvcreate RAID1 cache-pool, and lvconvert to cache
2015-09-10 16:07:59 +03:00
lvcreate --type raid1 -m 1 --nosync -l 2 -n $lv1 $vg
lvcreate --type raid1 -m 1 --nosync -l 2 -n ${ lv1 } _cachepool $vg
2014-10-07 12:12:39 +04:00
#should lvs -a $vg/${lv1}_cdata_rimage_0 # ensure images are properly renamed
2015-09-10 16:07:59 +03:00
lvconvert --yes --type cache --cachemode writeback --cachepool $vg /${ lv1 } _cachepool $vg /$lv1 2>& 1 | tee out
2017-11-20 18:33:43 +03:00
grep "WARNING: Data redundancy could be lost" out
2014-10-07 12:12:39 +04:00
check lv_exists $vg /${ lv1 } _corig_rimage_0 # ensure images are properly renamed
dmsetup table ${ vg } -$lv1 | grep cache # ensure it is loaded in kernel
lvremove -f $vg
2015-09-10 16:07:59 +03:00
lvcreate -n corigin -m 1 --type raid1 --nosync -l 10 $vg
lvcreate -n cpool --type cache $vg /corigin --cachemode writeback -l 10 2>& 1 | tee out
2017-11-20 18:33:43 +03:00
grep "WARNING: Data redundancy could be lost" out
2017-03-09 15:59:47 +03:00
not lvconvert --splitmirrors 1 --name split $vg /corigin " $dev1 "
lvconvert --yes --splitmirrors 1 --name split $vg /corigin " $dev1 "
2014-10-07 12:12:39 +04:00
lvremove -f $vg
lvcreate -n cpool_meta -m 1 --type raid1 -l 10 $vg
lvcreate -n cpool -m 1 --type raid1 -l 10 $vg
2014-11-13 23:52:02 +03:00
aux wait_for_sync $vg cpool_meta
2014-10-31 02:37:35 +03:00
aux wait_for_sync $vg cpool
2014-10-26 21:45:17 +03:00
lvs -a -o+seg_pe_ranges $vg
2014-10-07 12:12:39 +04:00
lvconvert --yes --type cache-pool --poolmetadata $vg /cpool_meta $vg /cpool
lvcreate -n corigin --type cache --cachepool $vg /cpool -l 10
2019-10-21 16:11:51 +03:00
lvchange --syncaction repair $vg /cpool_cpool_cmeta
aux wait_for_sync $vg cpool_cpool_cmeta
2016-09-22 16:46:18 +03:00
2019-10-21 16:11:51 +03:00
lvchange --syncaction repair $vg /cpool_cpool_cdata
aux wait_for_sync $vg cpool_cpool_cdata
2014-10-13 18:21:41 +04:00
2019-10-21 16:11:51 +03:00
lvconvert -y --repair $vg /cpool_cpool_cmeta
lvconvert -y --repair $vg /cpool_cpool_cdata
2014-10-07 12:12:39 +04:00
# do not allow reserved names for *new* LVs
2019-10-21 16:11:51 +03:00
not lvconvert --splitmirrors 1 --name split_cmeta $vg /cpool_cpool_cmeta " $dev1 "
not lvconvert --splitmirrors 1 --name split_cdata $vg /cpool_cpool_cdata " $dev1 "
2014-10-07 12:12:39 +04:00
# but allow manipulating existing LVs with reserved names
2019-10-21 16:11:51 +03:00
aux wait_for_sync $vg cpool_cpool_cmeta
aux wait_for_sync $vg cpool_cpool_cdata
lvconvert --yes --splitmirrors 1 --name split_meta $vg /cpool_cpool_cmeta " $dev1 "
lvconvert --yes --splitmirrors 1 --name split_data $vg /cpool_cpool_cdata " $dev1 "
not lvconvert --splitmirrors 1 --name split_data $vg /cpool_cpool_cdata " $dev1 "
2014-10-07 12:12:39 +04:00
2015-11-19 16:31:58 +03:00
lvremove -f $vg
# Test up/down raid conversion of cache pool data and metadata
2018-08-17 23:45:52 +03:00
lvcreate -l 10 -n cp1 $vg
lvconvert -y --type cache-pool $vg /cp1
lvcreate -l 20 -n co1 $vg
lvconvert -y --type cache --cachepool cp1 $vg /co1
2019-10-21 16:11:51 +03:00
lvconvert -y -m +1 --type raid1 $vg /cp1_cpool_cmeta
check lv_field $vg /cp1_cpool_cmeta layout "raid,raid1"
check lv_field $vg /cp1_cpool_cmeta role "private,cache,pool,metadata"
2018-08-17 23:45:52 +03:00
2019-10-21 16:11:51 +03:00
lvconvert -y -m +1 --type raid1 $vg /cp1_cpool_cdata
check lv_field $vg /cp1_cpool_cdata layout "raid,raid1"
check lv_field $vg /cp1_cpool_cdata role "private,cache,pool,data"
2018-08-17 23:45:52 +03:00
sleep 5
lvs -a -o+devices $vg
2019-10-21 16:11:51 +03:00
not lvconvert -m -1 $vg /cp1_cpool_cmeta
2018-08-17 23:45:52 +03:00
2019-10-21 16:11:51 +03:00
lvconvert -y -m -1 $vg /cp1_cpool_cmeta
check lv_field $vg /cp1_cpool_cmeta layout "linear"
lvconvert -y -m -1 $vg /cp1_cpool_cdata
check lv_field $vg /cp1_cpool_cdata layout "linear"
2015-11-19 16:31:58 +03:00
lvremove -f $vg
2014-10-07 12:12:39 +04:00
vgremove -f $vg