2017-07-02 22:38:32 +03:00
#!/usr/bin/env bash
2015-04-02 17:01:01 +03:00
# Copyright (C) 2015 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
2015-04-02 17:01:01 +03:00
# test currently needs to drop
# 'return NULL' in _lv_create_an_lv after log_error("Can't create %s without using "
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 }
2015-04-02 17:01:01 +03:00
. lib/inittest
aux have_thin 1 0 0 || skip
# Test --poolmetadatasize range
# allocating large devices for testing
aux prepare_pvs 10 16500
2017-07-06 20:41:25 +03:00
get_devs
2018-05-24 17:49:48 +03:00
vgcreate $SHARED -s 64K " $vg " " ${ DEVICES [@] } "
2015-04-02 17:01:01 +03:00
# Size 0 is not valid
invalid lvcreate -L4M --chunksize 128 --poolmetadatasize 0 -T $vg /pool1 2>out
2021-09-21 17:59:21 +03:00
lvcreate -Zn -L4M --chunksize 128 --poolmetadatasize 16k -T $vg /pool1 >out 2>& 1
2021-01-30 15:13:17 +03:00
grep -i "minimal" out
2015-04-02 17:01:01 +03:00
# FIXME: metadata allocation fails, if PV doesn't have at least 16GB
# i.e. pool metadata device cannot be multisegment
2021-09-21 17:59:21 +03:00
lvcreate -Zn -L4M --chunksize 64k --poolmetadatasize 17G -T $vg /pool2 >out 2>& 1
2021-01-30 15:13:17 +03:00
grep "maximum" out
2015-04-02 17:01:01 +03:00
check lv_field $vg /pool1_tmeta size "2.00m"
2021-01-30 15:13:17 +03:00
check lv_field $vg /pool2_tmeta size "<15.88g"
2017-04-08 20:38:17 +03:00
2017-06-24 18:24:38 +03:00
# Check we do report correct percent values.
lvcreate --type zero -L3G $vg -n pool3
lvconvert -y --thinpool $vg /pool3
lvchange --errorwhenfull y $vg /pool3
lvchange --zero n $vg /pool3
lvcreate -V10G $vg /pool3 -n $lv1
lvcreate -V2G $vg /pool3 -n $lv2
dd if = /dev/zero of = " $DM_DEV_DIR / $vg / $lv1 " bs = 512b count = 1 conv = fdatasync
# ...excercise write speed to 'zero' device ;)
2020-09-20 00:25:11 +03:00
dd if = /dev/zero of = " $DM_DEV_DIR / $vg / $lv2 " bs = 64K count = 32767 oflag = direct
2017-06-24 18:24:38 +03:00
lvs -a $vg
# Check the percentage is not shown as 0.00
check lv_field $vg /$lv1 data_percent "0.01"
# Check the percentage is not shown as 100.00
check lv_field $vg /$lv2 data_percent "99.99"
2017-04-08 20:38:17 +03:00
# Check can start and see thinpool with metadata size above kernel limit
lvcreate -L4M --poolmetadatasize 16G -T $vg /poolM
check lv_field $vg /poolM data_percent "0.00"
2015-04-02 17:01:01 +03:00
lvremove -ff $vg
# Test automatic calculation of pool metadata size
lvcreate -L160G -T $vg /pool
check lv_field $vg /pool lv_metadata_size "80.00m"
check lv_field $vg /pool chunksize "128.00k"
lvremove -ff $vg /pool
lvcreate -L10G --chunksize 256 -T $vg /pool1
lvcreate -L60G --chunksize 1024 -T $vg /pool2
check lv_field $vg /pool1_tmeta size "2.50m"
check lv_field $vg /pool2_tmeta size "3.75m"
lvremove -ff $vg
2019-01-29 00:05:17 +03:00
# Test chunk size is rounded to power-of-2
2015-04-02 17:01:01 +03:00
lvcreate -L10G --poolmetadatasize 4M -T $vg /pool
2019-01-29 00:05:17 +03:00
check lv_field $vg /pool chunk_size "256.00k"
2015-04-02 17:01:01 +03:00
# Old thinpool target required rounding to power of 2
aux lvmconf "global/thin_disabled_features = [ \"block_size\" ]"
lvcreate -L10G --poolmetadatasize 4M -T $vg /pool_old
check lv_field $vg /pool_old chunk_size "256.00k"
lvremove -ff $vg
# reset
#aux lvmconf "global/thin_disabled_features = []"
vgremove -ff $vg