2017-07-02 22:38:32 +03:00
#!/usr/bin/env bash
2014-04-01 17:51:46 +04: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-04-01 17:51:46 +04:00
#
# test thin profile functionality
#
2018-05-24 17:49:48 +03:00
2015-10-27 17:10:06 +03:00
SKIP_WITH_LVMPOLLD = 1
2015-05-17 18:22:18 +03:00
export LVM_TEST_THIN_REPAIR_CMD = ${ LVM_TEST_THIN_REPAIR_CMD -/bin/false }
2014-06-06 19:40:04 +04:00
. lib/inittest
2014-04-01 17:51:46 +04:00
DEV_SIZE = 32
2014-05-21 18:48:06 +04:00
# check we have thinp support compiled in
aux have_thin 1 0 0 || skip
2014-04-01 17:51:46 +04:00
aux prepare_profiles "thin-performance"
# Create scsi debug dev with sector size of 4096B and 1MiB optimal_io_size
2014-05-21 18:48:06 +04:00
aux prepare_scsi_debug_dev $DEV_SIZE sector_size = 4096 opt_blks = 256 || skip
2015-04-02 13:22:59 +03:00
EXPECT = 1048576
2015-04-24 21:31:22 +03:00
check sysfs " $( < SCSI_DEBUG_DEV) " queue/optimal_io_size " $EXPECT "
2017-07-03 21:55:11 +03:00
aux prepare_pvs 1 " $DEV_SIZE "
2015-04-02 13:22:59 +03:00
# Check we are not running on buggy kernel (broken lcm())
# If so, turn chunk_size test into 'should'
2017-07-11 12:18:22 +03:00
SHOULD = ""
2015-04-24 21:31:22 +03:00
check sysfs " $dev1 " queue/optimal_io_size " $EXPECT " || SHOULD = should
2015-04-02 13:22:59 +03:00
2018-05-24 17:49:48 +03:00
vgcreate $SHARED $vg " $dev1 "
2014-04-01 17:51:46 +04:00
# By default, "generic" policy is used to
# calculate chunk size which is 64KiB by default
# or minimum_io_size if it's higher. Also, zeroing is used
# under default operation.
lvcreate -L8m -T $vg /pool_generic
check lv_field $vg /pool_generic profile ""
check lv_field $vg /pool_generic chunk_size 64.00k
2014-07-10 17:30:28 +04:00
check lv_field $vg /pool_generic zero "zero"
2014-04-01 17:51:46 +04:00
# If "thin-performance" profile is used, the "performance"
# policy is used to calculate chunk size which is 512KiB
# or optimal_io_suize if it's higher. Our test device has
# 1MiB, so that should be used. Also, zeroing is not used
# under "thin-perforance" profile.
lvcreate --profile thin-performance -L8m -T $vg /pool_performance
check lv_field $vg /pool_performance profile "thin-performance"
2015-04-02 13:22:59 +03:00
$SHOULD check lv_field $vg /pool_performance chunk_size 1.00m
2014-07-10 17:30:28 +04:00
check lv_field $vg /pool_performance zero ""
2014-04-01 17:51:46 +04:00
2021-02-17 02:07:50 +03:00
lvremove -f $vg
#
# Repeat same two creations via lvconvert
#
lvcreate -L8m --name pool_generic $vg
lvconvert --yes --type thin-pool $vg /pool_generic
check lv_field $vg /pool_generic chunk_size 64.00k
check lv_field $vg /pool_generic zero "zero"
lvcreate -L8m --name pool_performance $vg
lvconvert --yes --type thin-pool --errorwhenfull y --profile thin-performance $vg /pool_performance
check lv_field $vg /pool_performance profile "thin-performance"
$SHOULD check lv_field $vg /pool_performance chunk_size 1.00m
check lv_field $vg /pool_performance zero ""
check lv_field $vg /pool_performance lv_when_full "error"
2014-04-01 17:51:46 +04:00
vgremove -ff $vg
2015-06-24 14:21:21 +03:00
if test -d " $DM_DEV_DIR / $vg " ; then
should not echo " Udev has left \" $DM_DEV_DIR / $vg \"! "
2017-07-07 12:50:33 +03:00
rm -rf " ${ DM_DEV_DIR : ?/dev } / $vg "
2015-06-24 14:21:21 +03:00
fi
2014-04-01 17:51:46 +04:00
# The profile must be also applied if using the profile
# for the whole VG - any LVs inherit this profile then.
2018-05-24 17:49:48 +03:00
vgcreate $SHARED --profile thin-performance $vg " $dev1 "
2014-04-01 17:51:46 +04:00
lvcreate -L8m -T $vg /pool_performance_inherited
# ...the LV does not have the profile attached, but VG does!
check vg_field $vg profile "thin-performance"
check lv_field $vg /pool_performance_inherited profile ""
2015-04-02 13:22:59 +03:00
$SHOULD check lv_field $vg /pool_performance_inherited chunk_size 1.00m
2014-07-10 17:30:28 +04:00
check lv_field $vg /pool_performance_inherited zero ""
2016-12-11 12:18:44 +03:00
vgremove -ff $vg