2017-07-02 22:38:32 +03:00
#!/usr/bin/env bash
2014-12-15 22:48:05 +03:00
# Copyright (C) 2014 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,
2016-01-21 13:49:46 +03:00
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2014-12-15 22:48:05 +03:00
# Exercise creation of cache and cache pool volumes
# Full CLI uses --type
# Shorthand CLI uses -H | --cache
2016-02-23 01:13:42 +03:00
SKIP_WITH_LVMLOCKD = 1
2015-10-27 17:10:06 +03:00
SKIP_WITH_LVMPOLLD = 1
2014-12-15 22:48:05 +03:00
2015-10-27 17:10:06 +03:00
. lib/inittest
2015-05-09 02:59:18 +03:00
2014-12-15 22:48:05 +03:00
aux have_cache 1 3 0 || skip
aux prepare_vg 5 8000
2016-12-01 12:45:37 +03:00
# Use 10M origin size
2016-12-08 18:27:24 +03:00
lvcreate -aey -L10 -n $lv1 $vg
2016-12-01 12:45:37 +03:00
lvcreate -H -L5 $vg /$lv1
# replace 10M size with 5M size of cache device
NEWCLINE = $( dmsetup table $vg -$lv1 | sed 's/20480/10240/' )
dmsetup reload $vg -$lv1 --table " $NEWCLINE "
dmsetup resume $vg -$lv1
# Check that mismatching cache target is shown by lvs
lvs -a $vg 2>& 1 | grep "WARNING"
check lv_attr_bit state $vg /$lv1 "X"
lvs -o+lv_active $vg
lvremove -f $vg
2014-12-15 22:48:05 +03:00
lvcreate --type cache-pool -L10 $vg /cpool
lvcreate --type cache -l 1 --cachepool $vg /cpool -n corigin $vg
lvs -o lv_name,cache_policy
lvs -o lv_name,cache_settings
lvremove -f $vg
lvcreate --type cache-pool -L10 $vg /cpool
lvcreate --type cache -l 1 --cachepool $vg /cpool -n corigin $vg --cachepolicy mq \
--cachesettings migration_threshold = 233
lvs -o lv_name,cache_policy | grep mq
lvs -o lv_name,cache_settings | grep migration_threshold = 233
lvremove -f $vg
lvcreate --type cache-pool -L10 --cachepolicy mq --cachesettings migration_threshold = 233 $vg /cpool
lvcreate --type cache -l 1 --cachepool $vg /cpool -n corigin $vg
lvs -o lv_name,cache_policy | grep mq
lvs -o lv_name,cache_settings | grep migration_threshold = 233
lvremove -f $vg
lvcreate --type cache-pool -L10 --cachepolicy mq --cachesettings migration_threshold = 233 --cachesettings sequential_threshold = 13 $vg /cpool
lvcreate --type cache -l 1 --cachepool $vg /cpool -n corigin $vg
lvs -o lv_name,cache_policy | grep mq
lvs -a -o lv_name,cache_policy -S 'cache_policy=mq' | grep corigin
lvs -o lv_name,cache_settings | grep migration_threshold = 233
lvs -o lv_name,cache_settings | grep sequential_threshold = 13
lvcreate -n foo -l 1 $vg
lvs -S 'cache_policy=mq' | grep corigin
lvs -S 'cache_policy=mq' | not grep foo
lvs -S 'cache_policy=undefined' | not grep corigin
lvs -S 'cache_policy=undefined' | grep foo
lvs -o +cache_policy -S 'cache_policy=mq' | grep corigin
lvs -o +cache_policy -S 'cache_policy=mq' | not grep foo
lvs -o +cache_policy -S 'cache_policy=undefined' | not grep corigin
lvs -o +cache_policy -S 'cache_policy=undefined' | grep foo
lvs -o +cache_policy -O cache_policy
2014-12-18 18:12:50 +03:00
lvs -o +cache_settings -S 'cache_settings={migration_threshold=233}' | grep corigin
lvs -o +cache_settings -S 'cache_settings!={migration_threshold=233}' | grep foo
lvs -o +cache_policy -O cache_settings
2014-12-15 22:48:05 +03:00
lvremove -f $vg
lvcreate -n foo -l 1 $vg
lvs -a -S 'cache_policy=undefined' | grep foo
2016-12-11 12:18:44 +03:00
vgremove -ff $vg