2017-07-02 22:38:32 +03:00
#!/usr/bin/env bash
2013-10-12 01:59:14 +04:00
# Copyright (C) 2008-2013 Red Hat, Inc. All rights reserved.
2007-09-18 18:02:22 +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,
2016-01-21 13:49:46 +03:00
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2007-09-18 18:01:46 +04:00
2008-09-30 21:47:34 +04:00
# 'Exercise some lvcreate diagnostics'
2007-09-18 18:01:46 +04:00
2016-02-23 01:13:42 +03:00
SKIP_WITH_LVMLOCKD = 1
2014-06-06 19:40:04 +04:00
. lib/inittest
2007-09-18 18:01:46 +04:00
2009-05-09 01:50:20 +04:00
aux prepare_pvs 4
2017-07-06 20:41:25 +03:00
get_devs
2012-03-16 17:00:05 +04:00
aux pvcreate --metadatacopies 0 " $dev1 "
2017-07-06 20:41:25 +03:00
aux vgcreate " $vg " " ${ DEVICES [@] } "
2007-09-18 18:01:46 +04:00
2014-10-11 11:12:56 +04:00
invalid lvcreate --type free -l1 -n $lv1 $vg 2>err
grep "Invalid argument for --type" err
invalid lvcreate --type $RANDOM -l1 -n $lv1 $vg
invalid lvcreate --type unknown -l1 -n $lv1 $vg
2017-07-16 12:18:13 +03:00
invalid lvcreate -L10000000000000000000 -n $lv $vg 2>& 1 | tee err
grep "Size is too big" err
invalid lvcreate -L+-10 -n $lv $vg 2>& 1 | tee err
grep "Multiple sign" err
invalid lvcreate -L-.1 -n $lv $vg 2>& 1 | tee err
grep "Size may not be negative" err
invalid lvcreate -L..1 -n $lv $vg 2>& 1 | tee err
grep "Can't parse size" err
2014-11-01 01:18:31 +03:00
lvcreate --type linear -aey -m0 -l1 -n $lv1 $vg
2014-10-11 11:12:56 +04:00
lvcreate --type snapshot -l1 -n $lv2 $vg /$lv1
2017-07-16 12:18:13 +03:00
# Supporting decimal point with size
lvcreate -L.1 -n $lv3 $vg
2014-10-11 11:12:56 +04:00
# Reject repeated invocation (run 2 times) (bz178216)
lvcreate -n $lv -l 4 $vg
2008-09-30 21:47:34 +04:00
not lvcreate -n $lv -l 4 $vg
lvremove -ff $vg /$lv
2014-10-11 11:12:56 +04:00
# Try to remove it again - should fail (but not segfault)
2009-07-14 23:35:35 +04:00
not lvremove -ff $vg /$lv
2007-09-18 18:01:46 +04:00
2014-10-11 11:12:56 +04:00
# Reject a negative stripe_size
invalid lvcreate -L 64m -n $lv -i2 --stripesize -4 $vg 2>err;
grep "may not be negative" err
2007-09-18 18:01:46 +04:00
2014-10-11 11:12:56 +04:00
# Reject a too-large stripesize
invalid lvcreate -L 64m -n $lv -i2 --stripesize 4294967291 $vg 2>err
2012-03-16 17:00:05 +04:00
grep "Stripe size cannot be larger than" err
2008-08-28 14:07:34 +04:00
2014-10-11 11:12:56 +04:00
# w/single stripe succeeds with diagnostics to stdout
2010-04-13 10:25:08 +04:00
lvcreate -L 64m -n $lv -i1 --stripesize 4 $vg 2> err | tee out
2012-03-16 17:00:05 +04:00
grep "Ignoring stripesize argument with single stripe" out
2014-10-11 11:12:56 +04:00
lvdisplay $vg
2008-09-30 21:47:34 +04:00
lvremove -ff $vg
2007-09-18 18:01:46 +04:00
2014-10-11 11:12:56 +04:00
# w/default (64KB) stripe size succeeds with diagnostics to stdout
2009-09-30 20:13:53 +04:00
lvcreate -L 64m -n $lv -i2 $vg > out
2012-03-16 17:00:05 +04:00
grep "Using default stripesize" out
2014-10-11 11:12:56 +04:00
lvdisplay $vg
2011-01-05 03:16:18 +03:00
check lv_field $vg /$lv stripesize "64.00k"
2008-09-30 21:47:34 +04:00
lvremove -ff $vg
2007-09-18 18:01:46 +04:00
2014-10-11 11:12:56 +04:00
# Reject an invalid number of stripes
invalid lvcreate -L 64m -n $lv -i129 $vg 2>err
2012-03-16 17:00:05 +04:00
grep "Number of stripes (129) must be between 1 and 128" err
2007-09-18 18:01:46 +04:00
2014-10-11 11:12:56 +04:00
# Reject an invalid stripe size
invalid lvcreate -L 64m -n $lv -i2 --stripesize 3 $vg 2>err
2012-03-16 17:00:05 +04:00
grep "Invalid stripe size" err
2014-10-11 11:12:56 +04:00
# Verify that the LV was not created via lvdisplay empty output
2012-03-16 17:00:05 +04:00
test -z " $( lvdisplay $vg ) "
2007-09-18 18:01:46 +04:00
2009-03-16 17:34:57 +03:00
# Setting max_lv works. (bz490298)
2014-10-11 11:12:56 +04:00
check vg_field $vg max_lv "0"
2009-05-14 01:29:10 +04:00
vgchange -l 3 $vg
2014-10-11 11:12:56 +04:00
check vg_field $vg max_lv "3"
2013-10-12 01:59:14 +04:00
lvcreate -aey -l1 -n $lv1 $vg
2009-03-16 17:34:57 +03:00
lvcreate -l1 -s -n $lv2 $vg /$lv1
lvcreate -l1 -n $lv3 $vg
2014-10-11 11:12:56 +04:00
fail lvcreate -l1 -n $lv4 $vg
2009-05-14 01:29:10 +04:00
lvremove -ff $vg /$lv3
2014-10-11 11:12:56 +04:00
# Check snapshot of inactive origin
2012-11-21 12:46:18 +04:00
lvchange -an $vg /$lv1
2009-05-14 01:29:10 +04:00
lvcreate -l1 -s -n $lv3 $vg /$lv1
2014-10-11 11:12:56 +04:00
fail lvcreate -l1 -n $lv4 $vg
fail lvcreate -l1 --type mirror -m1 -n $lv4 $vg
2009-05-14 01:29:10 +04:00
lvremove -ff $vg /$lv3
2013-10-12 01:59:14 +04:00
lvcreate -aey -l1 --type mirror -m1 -n $lv3 $vg
2009-05-14 01:29:10 +04:00
not lvcreate -l1 -n $lv4 $vg
2013-08-08 00:48:31 +04:00
not lvcreate -l1 --type mirror -m1 -n $lv4 $vg
2009-05-14 01:29:10 +04:00
lvconvert -m0 $vg /$lv3
2013-10-08 18:56:09 +04:00
lvconvert -m2 --type mirror -i 1 $vg /$lv3
2009-05-14 01:29:10 +04:00
lvconvert -m1 $vg /$lv3
2014-10-11 11:12:56 +04:00
fail vgchange -l 2
check vg_field $vg max_lv "3"
2009-05-14 01:29:10 +04:00
vgchange -l 4
2014-10-11 11:12:56 +04:00
check vg_field $vg max_lv "4"
2009-05-14 01:29:10 +04:00
2009-03-16 17:34:57 +03:00
lvremove -ff $vg
vgchange -l 0 $vg
2014-10-11 11:12:56 +04:00
check vg_field $vg max_lv "0"
2009-05-08 08:24:52 +04:00
2014-10-11 11:12:56 +04:00
# Rejects invalid chunksize, accepts between 4K and 512K
# and validate origin_size
2013-10-12 01:59:14 +04:00
lvcreate -aey -L 32m -n $lv1 $vg
2009-09-30 20:13:53 +04:00
not lvcreate -L 8m -n $lv2 -s --chunksize 3k $vg /$lv1
not lvcreate -L 8m -n $lv2 -s --chunksize 1024k $vg /$lv1
lvcreate -L 8m -n $lv2 -s --chunksize 4k $vg /$lv1
2012-03-16 17:00:05 +04:00
check lv_field $vg /$lv2 chunk_size "4.00k"
check lv_field $vg /$lv2 origin_size "32.00m"
2009-09-30 20:13:53 +04:00
lvcreate -L 8m -n $lv3 -s --chunksize 512k $vg /$lv1
2012-03-16 17:00:05 +04:00
check lv_field $vg /$lv3 chunk_size "512.00k"
check lv_field $vg /$lv3 origin_size "32.00m"
2014-10-11 11:12:56 +04:00
lvremove -f $vg
2009-05-08 08:24:52 +04:00
2014-10-11 11:12:56 +04:00
# Mirror regionsize must be
2009-05-09 01:50:20 +04:00
# - nonzero (bz186013)
# - a power of 2 and a multiple of page size
# - <= size of LV
2014-10-26 09:29:25 +03:00
invalid lvcreate --type mirror -m 1 -L 32m -n $lv -R 0 $vg 2>err
2014-10-11 11:12:56 +04:00
grep "may not be zero" err
2014-10-26 09:29:25 +03:00
invalid lvcreate --type mirror -m 1 -L 32m -n $lv -R 11k $vg
invalid lvcreate --type mirror -m 1 -L 32m -n $lv -R 1k $vg
2013-10-12 01:59:14 +04:00
lvcreate -aey -L 32m -n $lv --regionsize 128m --type mirror -m 1 $vg
2011-01-05 03:16:18 +03:00
check lv_field $vg /$lv regionsize "32.00m"
2014-10-11 11:12:56 +04:00
lvremove -f $vg
2013-10-12 01:59:14 +04:00
lvcreate -aey -L 32m -n $lv --regionsize 4m --type mirror -m 1 $vg
2011-01-05 03:16:18 +03:00
check lv_field $vg /$lv regionsize "4.00m"
2014-10-11 11:12:56 +04:00
# -m0 is creating non-mirrored segment and give info about redundant option
2015-05-14 11:20:24 +03:00
lvcreate -m 0 -l1 -n $lv1 $vg 2>& 1 | tee err
2014-10-11 11:12:56 +04:00
grep "Redundant" err
check lv_field $vg /$lv1 segtype "linear"
2009-05-09 01:50:20 +04:00
lvremove -ff $vg
2014-10-31 01:16:03 +03:00
# Old --type snapshot works with -s
lvcreate --type snapshot -s -V64 -L32 -n $lv1 $vg
check lv_field $vg /$lv1 segtype "linear"
lvcreate --type snapshot -V64 -L32 -n $lv2 $vg
check lv_field $vg /$lv2 segtype "linear"
lvremove -ff $vg
# --virtualoriginsize always makes old snapshot
2009-09-30 20:13:53 +04:00
lvcreate -s --virtualoriginsize 64m -L 32m -n $lv1 $vg
2014-10-31 01:16:03 +03:00
check lv_field $vg /$lv1 segtype "linear"
2009-06-01 19:55:06 +04:00
lvrename $vg /$lv1 $vg /$lv2
2009-09-30 20:13:53 +04:00
lvcreate -s --virtualoriginsize 64m -L 32m -n $lv1 $vg
2009-06-01 19:55:06 +04:00
lvchange -a n $vg /$lv1
2011-11-18 23:25:20 +04:00
lvremove -ff $vg /$lv1
2009-06-01 19:55:06 +04:00
lvremove -ff $vg
2009-12-03 04:48:05 +03:00
# readahead default (auto), none, #, auto
2014-10-11 11:12:56 +04:00
lvcreate -L 8 -n $lv1 $vg
check lv_field $vg /$lv1 lv_read_ahead "auto"
lvcreate -L 8 -n $lv2 --readahead none $vg
check lv_field $vg /$lv2 lv_read_ahead "0"
check lv_field $vg /$lv2 lv_kernel_read_ahead "0"
lvcreate -L 8 -n $lv3 --readahead 8k $vg
check lv_field $vg /$lv3 lv_read_ahead "8.00k"
check lv_field $vg /$lv3 lv_kernel_read_ahead "8.00k"
lvcreate -L 8 -n $lv4 --readahead auto $vg
check lv_field $vg /$lv4 lv_read_ahead "auto"
check lv_field $vg /$lv4 lv_kernel_read_ahead "128.00k"
lvcreate -L 8 -n $lv5 -i2 --stripesize 16k --readahead auto $vg
check lv_field $vg /$lv5 lv_read_ahead "auto"
check lv_field $vg /$lv5 lv_kernel_read_ahead "128.00k"
lvcreate -L 8 -n $lv6 -i2 --stripesize 128k --readahead auto $vg
check lv_field $vg /$lv6 lv_read_ahead "auto"
check lv_field $vg /$lv6 lv_kernel_read_ahead "512.00k"
2009-12-03 04:48:05 +03:00
lvremove -ff $vg
2014-04-07 22:27:34 +04:00
2014-10-11 11:12:56 +04:00
#
# Validate --major --minor, we need to know VG, thus failing
#
fail lvcreate -My --major 234 -l1 $vg
# cannot specify --major or --minor with -Mn
fail lvcreate -Mn --major 234 -l1 $vg
fail lvcreate --persistent n --minor 234 -l1 $vg
# out-of-range minor value
fail lvcreate --minor 9999999 -l1 $vg
2015-04-30 14:23:56 +03:00
if aux kernel_at_least 2 4 0; then
2014-10-11 11:12:56 +04:00
# On >2.4 we ignore --major
2015-05-14 11:20:24 +03:00
lvcreate --major 234 -l1 $vg 2>& 1 | tee err;
2014-10-11 11:12:56 +04:00
grep "Ignoring" err
# Try some bigger possibly unused minor
if test ! -d /sys/block/dm-2345; then
lvcreate --minor 2345 -l1 -n $lv1 $vg
check lv_field $vg /$lv1 lv_kernel_minor "2345"
fi
if test ! -d /sys/block/dm-23456; then
lvcreate -My --minor 23456 -j 122 -l1 -n $lv2 $vg
check lv_field $vg /$lv2 lv_kernel_minor "23456"
fi
fi # 2.4
lvremove -f $vg
2014-04-07 22:27:34 +04:00
# prohibited names
for i in pvmove snapshot ; do
invalid lvcreate -l1 -n ${ i } 1 $vg
done
for i in _cdata _cmeta _mimage _mlog _pmspare _tdata _tmeta _vorigin ; do
invalid lvcreate -l1 -n s_${ i } _1 $vg
done
2014-10-11 11:12:56 +04:00
# Check invalid error for pool-only options
invalid lvcreate --poolmetadataspare y -l1 $vg
invalid lvcreate --poolmetadatasize 10 -l1 $vg
invalid lvcreate --discards passdown -l1 $vg