2011-09-16 16:23:59 +04:00
#!/bin/sh
2013-07-15 15:37:07 +04:00
# Copyright (C) 2011-2013 Red Hat, Inc. All rights reserved.
2011-09-16 16:23:59 +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,
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# test currently needs to drop
# 'return NULL' in _lv_create_an_lv after log_error("Can't create %s without using "
. lib/test
2011-11-10 16:44:33 +04:00
check_lv_field_modules_( )
{
mod = $1
shift
2011-09-16 16:23:59 +04:00
2011-11-10 16:44:33 +04:00
for d in $* ; do
check lv_field $vg /$d modules $mod
done
}
#
# Main
#
2012-10-10 02:20:22 +04:00
aux have_thin 1 0 0 || skip
2014-02-27 02:25:30 +04:00
which mkfs.ext4 || skip
2011-11-10 16:44:33 +04:00
2012-03-04 20:04:52 +04:00
aux prepare_pvs 2 64
2011-11-10 16:44:33 +04:00
2012-10-10 21:00:46 +04:00
vgcreate $vg -s 64K $( cat DEVICES)
2011-09-16 16:23:59 +04:00
2011-11-10 16:44:33 +04:00
# Create named pool only
lvcreate -l1 -T $vg /pool1
lvcreate -l1 -T --thinpool $vg /pool2
lvcreate -l1 -T --thinpool pool3 $vg
lvcreate -l1 --type thin $vg /pool4
lvcreate -l1 --type thin --thinpool $vg /pool5
lvcreate -l1 --type thin --thinpool pool6 $vg
2011-12-21 17:45:42 +04:00
lvcreate -l1 --type thin-pool $vg /pool7
lvcreate -l1 --type thin-pool --thinpool $vg /pool8
lvcreate -l1 --type thin-pool --thinpool pool9 $vg
2011-11-10 16:44:33 +04:00
lvremove -ff $vg /pool1 $vg /pool2 $vg /pool3 $vg /pool4 $vg /pool5 $vg /pool6 $vg /pool7 $vg /pool8 $vg /pool9
check vg_field $vg lv_count 0
2011-09-16 16:23:59 +04:00
# Create default pool name
2011-11-10 16:44:33 +04:00
lvcreate -l1 -T $vg
lvcreate -l1 --type thin $vg
2011-12-21 17:45:42 +04:00
lvcreate -l1 --type thin-pool $vg
2011-09-16 16:23:59 +04:00
2013-07-15 15:37:07 +04:00
lvremove -ff $vg
2011-11-10 16:44:33 +04:00
check vg_field $vg lv_count 0
2011-09-16 16:23:59 +04:00
# Create default pool and default thin LV
2011-11-10 16:44:33 +04:00
lvcreate -l1 -V2G -T $vg
lvcreate -l1 -V2G --type thin $vg
2011-09-16 16:23:59 +04:00
2011-11-10 16:44:33 +04:00
lvremove -ff $vg
2011-09-16 16:23:59 +04:00
2011-11-10 16:44:33 +04:00
# Create named pool and default thin LV
2013-07-15 15:37:07 +04:00
lvcreate -L4M -V2G --name lvo1 -T $vg /pool1
lvcreate -L4M -V2G --name lvo2 -T --thinpool $vg /pool2
lvcreate -L4M -V2G --name lvo3 -T --thinpool pool3 $vg
lvcreate -L4M -V2G --name lvo4 --type thin $vg /pool4
lvcreate -L4M -V2G --name lvo5 --type thin --thinpool $vg /pool5
lvcreate -L4M -V2G --name lvo6 --type thin --thinpool pool6 $vg
check lv_exists $vg lvo1 lvo2 lvo3 lvo4 lvo5 lvo6
2011-11-10 16:44:33 +04:00
lvremove -ff $vg
2011-09-16 16:23:59 +04:00
2011-11-10 16:44:33 +04:00
# Create named pool and named thin LV
lvcreate -L4M -V2G -T $vg /pool1 --name lv1
lvcreate -L4M -V2G -T $vg /pool2 --name $vg /lv2
lvcreate -L4M -V2G -T --thinpool $vg /pool3 --name lv3
lvcreate -L4M -V2G -T --thinpool $vg /pool4 --name $vg /lv4
lvcreate -L4M -V2G -T --thinpool pool5 --name lv5 $vg
lvcreate -L4M -V2G -T --thinpool pool6 --name $vg /lv6 $vg
2011-09-16 16:23:59 +04:00
2012-03-16 17:00:05 +04:00
check lv_exists $vg lv1 lv2 lv3 lv4 lv5 lv6
2011-11-10 16:44:33 +04:00
lvremove -ff $vg
2011-09-16 16:23:59 +04:00
2011-11-10 16:44:33 +04:00
lvcreate -L4M -V2G --type thin $vg /pool1 --name lv1
lvcreate -L4M -V2G --type thin $vg /pool2 --name $vg /lv2
lvcreate -L4M -V2G --type thin --thinpool $vg /pool3 --name lv3
lvcreate -L4M -V2G --type thin --thinpool $vg /pool4 --name $vg /lv4
lvcreate -L4M -V2G --type thin --thinpool pool5 --name lv5 $vg
lvcreate -L4M -V2G --type thin --thinpool pool6 --name $vg /lv6 $vg
2011-09-16 16:23:59 +04:00
2012-03-16 17:00:05 +04:00
check lv_exists $vg lv1 lv2 lv3 lv4 lv5 lv6
2011-11-10 16:44:33 +04:00
lvremove -ff $vg
2011-09-16 16:23:59 +04:00
2011-11-10 16:44:33 +04:00
# Create default thin LV in existing pool
lvcreate -L4M -T $vg /pool
2013-07-15 15:37:07 +04:00
lvcreate -V2G --name lvo0 -T $vg /pool
lvcreate -V2G --name lvo1 -T --thinpool $vg /pool
lvcreate -V2G --name lvo2 -T --thinpool pool $vg
lvcreate -V2G --name lvo3 --type thin $vg /pool
lvcreate -V2G --name lvo4 --type thin --thinpool $vg /pool
lvcreate -V2G --name lvo5 --type thin --thinpool pool $vg
2011-09-16 16:23:59 +04:00
2013-07-15 15:37:07 +04:00
check lv_exists $vg lvo0 lvo1 lvo2 lvo3 lvo4 lvo5
2011-09-16 16:23:59 +04:00
2011-11-10 16:44:33 +04:00
# Create named thin LV in existing pool
2011-09-16 16:23:59 +04:00
lvcreate -V2G -T $vg /pool --name lv1
lvcreate -V2G -T $vg /pool --name $vg /lv2
lvcreate -V2G -T --thinpool $vg /pool --name lv3
lvcreate -V2G -T --thinpool $vg /pool --name $vg /lv4
lvcreate -V2G -T --thinpool pool --name lv5 $vg
lvcreate -V2G -T --thinpool pool --name $vg /lv6 $vg
lvcreate -V2G --type thin $vg /pool --name lv7
lvcreate -V2G --type thin $vg /pool --name $vg /lv8
lvcreate -V2G --type thin --thinpool $vg /pool --name lv9
lvcreate -V2G --type thin --thinpool $vg /pool --name $vg /lv10
lvcreate -V2G --type thin --thinpool pool --name lv11 $vg
lvcreate -V2G --type thin --thinpool pool --name $vg /lv12 $vg
2012-03-16 17:00:05 +04:00
check lv_exists $vg lv1 lv2 lv3 lv4 lv5 lv6 lv7 lv8 lv9 lv10 lv11 lv12
2011-09-16 16:23:59 +04:00
check vg_field $vg lv_count 19
2013-11-11 13:05:45 +04:00
check lv_field $vg /lv1 thin_id 7
2011-11-10 16:44:33 +04:00
lvremove -ff $vg
check vg_field $vg lv_count 0
2011-09-16 16:23:59 +04:00
2011-11-10 16:44:33 +04:00
# Create thin snapshot of thinLV
2011-11-10 19:30:59 +04:00
lvcreate -L10M -V10M -T $vg /pool --name lv1
2014-02-23 02:08:55 +04:00
mkfs.ext4 " $DM_DEV_DIR / $vg /lv1 "
2013-07-15 15:37:07 +04:00
lvcreate -K -s $vg /lv1 --name snap_lv1
2014-02-23 02:08:55 +04:00
fsck -n " $DM_DEV_DIR / $vg /snap_lv1 "
2013-07-15 15:37:07 +04:00
lvcreate -s $vg /lv1 --name lv2
lvcreate -s $vg /lv1 --name $vg /lv3
2013-07-15 18:38:55 +04:00
lvcreate --type snapshot $vg /lv1 --name lv6
2013-07-15 15:37:07 +04:00
lvcreate --type snapshot $vg /lv1 --name lv4
lvcreate --type snapshot $vg /lv1 --name $vg /lv5
2013-07-18 18:06:26 +04:00
check_lv_field_modules_ thin-pool,thin lv1 snap_lv1 lv2 lv3 lv4 lv5 lv6
2011-11-10 16:44:33 +04:00
check vg_field $vg lv_count 8
lvremove -ff $vg
# Normal Snapshots of thinLV
lvcreate -L4M -V2G -T $vg /pool --name lv1
2013-07-15 15:37:07 +04:00
lvcreate -s $vg /lv1 -l1 --name snap_lv1
lvcreate -s $vg /lv1 -l1 --name lv2
lvcreate -s $vg /lv1 -l1 --name $vg /lv3
lvcreate -s lv1 -L4M --name $vg /lv4
2011-11-10 16:44:33 +04:00
2013-07-15 15:37:07 +04:00
check_lv_field_modules_ snapshot snap_lv1 lv2 lv3 lv4
2011-11-10 16:44:33 +04:00
check vg_field $vg lv_count 6
lvremove -ff $vg
2011-09-16 16:23:59 +04:00
check vg_field $vg lv_count 0
2012-10-13 23:57:33 +04:00
lvdisplay $vg
2011-11-10 16:44:33 +04:00
# Fail cases
# Too small pool size (1 extent 64KB) for given chunk size
not lvcreate --chunksize 256 -l1 -T $vg /pool1
# Too small chunk size (min is 64KB - 128 sectors)
not lvcreate --chunksize 32 -l1 -T $vg /pool1
2012-03-16 17:00:05 +04:00
# Too large chunk size (max is 1GB)
not lvcreate -L4M --chunksize 2G -T $vg /pool1
2011-11-10 16:44:33 +04:00
2014-03-12 03:25:59 +04:00
# Test creation of inactive pool
lvcreate -an -L4M -T $vg /pool1
lvcreate -V2G --name lv1 -T $vg /pool1
2014-03-17 02:47:43 +04:00
# Check we are able remove spare volume if we want to
lvremove -f $vg /lvol0_pmspare
2011-11-10 16:44:33 +04:00
# Origin name is not accepted
2013-07-15 15:37:07 +04:00
not lvcreate -s $vg /lv1 -L4M -V2G --name $vg /lv4
2012-03-04 20:04:52 +04:00
2013-08-08 00:48:31 +04:00
# Check we cannot create mirror/raid1 and thin or thinpool together
2012-10-12 14:18:06 +04:00
not lvcreate -T mirpool -L4M --alloc anywhere -m1 $vg
not lvcreate --thinpool mirpool -L4M --alloc anywhere -m1 $vg
vgremove -ff $vg
2012-03-04 20:04:52 +04:00
2012-03-16 17:00:05 +04:00
# Test --poolmetadatasize range
2012-03-04 20:04:52 +04:00
# allocating large devices for testing
aux teardown_devs
2012-03-16 17:00:05 +04:00
aux prepare_pvs 10 16500
2012-10-12 14:18:06 +04:00
vgcreate $vg -s 64K $( cat DEVICES)
2012-03-04 20:04:52 +04:00
lvcreate -L4M --chunksize 128 --poolmetadatasize 0 -T $vg /pool1 2>out
grep "WARNING: Minimum" out
# FIXME: metadata allocation fails, if PV doesn't have at least 16GB
# i.e. pool metadata device cannot be multisegment
2012-03-16 17:00:05 +04:00
lvcreate -L4M --chunksize 64k --poolmetadatasize 17G -T $vg /pool2 2>out
2012-03-04 20:04:52 +04:00
grep "WARNING: Maximum" out
check lv_field $vg /pool1_tmeta size "2.00m"
check lv_field $vg /pool2_tmeta size "16.00g"
lvremove -ff $vg
2012-03-16 17:00:05 +04:00
# 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
2012-03-04 20:04:52 +04:00
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"
vgremove -ff $vg