2014-11-19 20:49:15 +03:00
#!/bin/sh
2016-03-02 13:12:14 +03:00
# Copyright (C) 2014-2016 Red Hat, Inc. All rights reserved.
2014-11-19 20:49:15 +03: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-11-19 20:49:15 +03:00
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-11-19 20:49:15 +03:00
2015-10-27 17:10:06 +03:00
. lib/inittest
2015-05-09 02:59:18 +03:00
2014-11-19 20:49:15 +03:00
aux have_cache 1 3 0 || skip
aux prepare_vg 3
2015-08-12 15:18:28 +03:00
aux lvmconf 'global/cache_disabled_features = [ "policy_smq" ]'
2014-11-19 20:49:15 +03:00
lvcreate --type cache-pool -an -v -L 2 -n cpool $vg
lvcreate -H -L 4 -n corigin --cachepool $vg /cpool
lvcreate -n noncache -l 1 $vg
2015-03-17 11:44:26 +03:00
# cannot change major minor for pools
not lvchange --yes -M y --minor 235 --major 253 $vg /cpool
not lvchange -M n $vg /cpool
2014-11-20 13:30:19 +03:00
not lvchange --cachepolicy mq $vg /noncache
not lvchange --cachesettings foo = bar $vg /noncache
2014-11-19 20:49:15 +03:00
2015-02-24 13:36:30 +03:00
lvchange --cachepolicy cleaner $vg /corigin
2016-03-02 13:12:14 +03:00
check lv_field $vg /corigin kernel_cache_policy "cleaner"
2015-02-24 13:36:30 +03:00
2016-07-13 17:13:29 +03:00
# Skip these test on older cache driver as it shows errors with these lvchanges
# device-mapper: space map common: index_check failed: blocknr 17179869216 != wanted 11
if aux have_cache 1 5 0 ; then
2014-11-20 13:30:19 +03:00
lvchange --cachepolicy mq --cachesettings migration_threshold = 333 $vg /corigin
2016-03-02 13:12:14 +03:00
# TODO once mq->smq happens we will get here some 0 for mq settings
check lv_field $vg /corigin kernel_cache_policy "mq"
get lv_field $vg /corigin kernel_cache_settings | grep 'migration_threshold=333'
2014-11-19 20:49:15 +03:00
lvchange --refresh $vg /corigin
2016-03-02 13:12:14 +03:00
get lv_field $vg /corigin kernel_cache_settings | grep 'migration_threshold=333'
2014-11-19 20:49:15 +03:00
lvchange -an $vg
lvchange -ay $vg
2016-03-02 13:12:14 +03:00
get lv_field $vg /corigin kernel_cache_settings | grep 'migration_threshold=333'
2014-11-19 20:49:15 +03:00
2014-11-20 13:30:19 +03:00
lvchange --cachesettings 'migration_threshold = 233 sequential_threshold = 13' $vg /corigin
2016-03-02 13:12:14 +03:00
get lv_field $vg /corigin kernel_cache_settings | tee out
grep 'migration_threshold=233' out
2016-03-31 12:59:55 +03:00
if grep 'sequential_threshold=13' out ; then
2014-11-19 20:49:15 +03:00
2014-11-20 14:05:40 +03:00
lvchange --cachesettings 'migration_threshold = 17' $vg /corigin
2016-03-02 13:12:14 +03:00
get lv_field $vg /corigin kernel_cache_settings | tee out
grep 'migration_threshold=17' out
grep 'sequential_threshold=13' out
2014-11-20 14:05:40 +03:00
lvchange --cachesettings 'migration_threshold = default' $vg /corigin
2016-03-02 13:12:14 +03:00
get lv_field $vg /corigin kernel_cache_settings | tee out
grep 'migration_threshold=2048' out
grep 'sequential_threshold=13' out
2014-11-20 14:05:40 +03:00
lvchange --cachesettings 'migration_threshold = 233 sequential_threshold = 13 random_threshold = 1' $vg /corigin
lvchange --cachesettings 'random_threshold = default migration_threshold = default' $vg /corigin
2016-03-02 13:12:14 +03:00
get lv_field $vg /corigin kernel_cache_settings | tee out
grep 'migration_threshold=2048' out
grep 'sequential_threshold=13' out
grep 'random_threshold=4' out
2014-11-20 14:05:40 +03:00
2014-11-20 14:35:51 +03:00
lvchange --cachesettings migration_threshold = 233 --cachesettings sequential_threshold = 13 --cachesettings random_threshold = 1 $vg /corigin
2016-03-02 13:12:14 +03:00
get lv_field $vg /corigin kernel_cache_settings | tee out
grep 'migration_threshold=233' out
grep 'sequential_threshold=13' out
grep 'random_threshold=1' out
2014-11-20 14:35:51 +03:00
lvchange --cachesettings random_threshold = default --cachesettings migration_threshold = default $vg /corigin
2016-03-02 13:12:14 +03:00
get lv_field $vg /corigin kernel_cache_settings | tee out
grep 'migration_threshold=2048' out
grep 'sequential_threshold=13' out
grep 'random_threshold=4' out
2014-11-20 14:35:51 +03:00
2016-03-31 12:59:55 +03:00
else
# When MQ is emulated by SMQ policy it does not hold settings.
# So just skip testing of param changes when sequential_threshold=0
grep 'sequential_threshold=0' out
fi
2016-07-13 17:13:29 +03:00
fi # have_cache 1 5 0
2014-11-19 20:49:15 +03:00
vgremove -f $vg