2007-09-18 18:01:46 +04:00
#!/bin/sh
2008-09-30 21:47:34 +04:00
# Copyright (C) 2008 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,
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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
2008-09-30 21:47:34 +04:00
. ./test-utils.sh
2007-09-18 18:01:46 +04:00
2009-05-09 01:50:20 +04:00
aux prepare_pvs 4
2008-11-10 15:37:03 +03:00
aux pvcreate --metadatacopies 0 $dev1
vgcreate -cn $vg $devs
2007-09-18 18:01:46 +04:00
2008-11-10 15:37:03 +03:00
# "lvcreate rejects repeated invocation (run 2 times) (bz178216)"
2008-09-30 21:47:34 +04:00
lvcreate -n $lv -l 4 $vg
not lvcreate -n $lv -l 4 $vg
lvremove -ff $vg /$lv
2009-07-14 23:35:35 +04:00
# try to remove it again - should fail (but not segfault)
not lvremove -ff $vg /$lv
2007-09-18 18:01:46 +04:00
2008-09-30 21:47:34 +04:00
# "lvcreate rejects a negative stripe_size"
2009-09-30 20:13:53 +04:00
not lvcreate -L 64m -n $lv -i2 --stripesize -4 $vg 2>err;
2008-09-30 21:47:34 +04:00
grep "^ Negative stripesize is invalid\$" err
2007-09-18 18:01:46 +04:00
2008-09-30 21:47:34 +04:00
# 'lvcreate rejects a too-large stripesize'
2009-09-30 20:13:53 +04:00
not lvcreate -L 64m -n $lv -i2 --stripesize 4294967291 $vg 2>err
grep "^ Stripe size cannot be larger than" err
2008-08-28 14:07:34 +04:00
2008-09-30 21:47:34 +04:00
# 'lvcreate 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
2008-09-30 21:47:34 +04:00
grep "^ Ignoring stripesize argument with single stripe\$" out
lvdisplay $vg
lvremove -ff $vg
2007-09-18 18:01:46 +04:00
2008-09-30 21:47:34 +04:00
# 'lvcreate 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
2008-09-30 21:47:34 +04:00
grep "^ Using default stripesize" out
lvdisplay $vg
2009-09-30 20:13:53 +04: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
2008-09-30 21:47:34 +04:00
# 'lvcreate rejects an invalid number of stripes'
2009-09-30 20:13:53 +04:00
not lvcreate -L 64m -n $lv -i129 $vg 2>err
2008-09-30 21:47:34 +04:00
grep "^ Number of stripes (129) must be between 1 and 128\$" err
2007-09-18 18:01:46 +04:00
# The case on lvdisplay output is to verify that the LV was not created.
2008-09-30 21:47:34 +04:00
# 'lvcreate rejects an invalid stripe size'
2009-09-30 20:13:53 +04:00
not lvcreate -L 64m -n $lv -i2 --stripesize 3 $vg 2>err
grep "^ Invalid stripe size" err
2008-09-30 21:50:56 +04:00
case $( lvdisplay $vg ) in "" ) true ; ; *) false ; ; esac
2007-09-18 18:01:46 +04:00
2009-03-16 17:34:57 +03:00
# Setting max_lv works. (bz490298)
2009-05-14 01:29:10 +04:00
lvremove -ff $vg
vgchange -l 3 $vg
2009-03-16 17:34:57 +03:00
lvcreate -l1 -n $lv1 $vg
lvcreate -l1 -s -n $lv2 $vg /$lv1
lvcreate -l1 -n $lv3 $vg
not lvcreate -l1 -n $lv4 $vg
2009-05-14 01:29:10 +04:00
lvremove -ff $vg /$lv3
lvcreate -l1 -s -n $lv3 $vg /$lv1
not lvcreate -l1 -n $lv4 $vg
not lvcreate -l1 -m1 -n $lv4 $vg
lvremove -ff $vg /$lv3
lvcreate -l1 -m1 -n $lv3 $vg
lvs
vgs -o +max_lv
not lvcreate -l1 -n $lv4 $vg
not lvcreate -l1 -m1 -n $lv4 $vg
lvconvert -m0 $vg /$lv3
lvconvert -m2 -i 1 $vg /$lv3
lvconvert -m1 $vg /$lv3
not vgchange -l 2
vgchange -l 4
2009-03-16 17:34:57 +03:00
vgs $vg
2009-05-14 01:29:10 +04:00
2009-03-16 17:34:57 +03:00
lvremove -ff $vg
vgchange -l 0 $vg
2009-05-08 08:24:52 +04:00
# lvcreate rejects invalid chunksize, accepts between 4K and 512K
# validate origin_size
vgremove -ff $vg
vgcreate -cn $vg $devs
2009-09-30 20:13:53 +04:00
lvcreate -L 32m -n $lv1 $vg
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
check_lv_field_ $vg /$lv2 chunk_size 4.00k
check_lv_field_ $vg /$lv2 origin_size 32.00m
lvcreate -L 8m -n $lv3 -s --chunksize 512k $vg /$lv1
check_lv_field_ $vg /$lv3 chunk_size 512.00k
check_lv_field_ $vg /$lv3 origin_size 32.00m
2009-05-08 08:24:52 +04:00
lvremove -ff $vg
vgchange -l 0 $vg
2009-05-09 01:50:20 +04:00
# regionsize must be
# - nonzero (bz186013)
# - a power of 2 and a multiple of page size
# - <= size of LV
2009-09-30 20:13:53 +04:00
not lvcreate -L 32m -n $lv -R0 $vg 2>err
2009-05-09 01:50:20 +04:00
grep "Non-zero region size must be supplied." err
2009-09-30 20:13:53 +04:00
not lvcreate -L 32m -n $lv -R 11k $vg
not lvcreate -L 32m -n $lv -R 1k $vg
lvcreate -L 32m -n $lv --regionsize 128m -m 1 $vg
check_lv_field_ $vg /$lv regionsize "32.00m"
2009-05-09 01:50:20 +04:00
lvremove -ff $vg
2009-09-30 20:13:53 +04:00
lvcreate -L 32m -n $lv --regionsize 4m -m 1 $vg
check_lv_field_ $vg /$lv regionsize "4.00m"
2009-05-09 01:50:20 +04:00
lvremove -ff $vg
2009-06-01 19:55:06 +04:00
# snapshot with virtual origin works
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
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
lvremove $vg /$lv1
lvremove -ff $vg
2009-12-03 04:48:05 +03:00
# readahead default (auto), none, #, auto
lvcreate -L 32m -n $lv $vg
check_lv_field_ $vg /$lv lv_read_ahead "auto"
lvremove -ff $vg
lvcreate -L 32m -n $lv --readahead none $vg
check_lv_field_ $vg /$lv lv_read_ahead "0"
lvremove -ff $vg
lvcreate -L 32m -n $lv --readahead 8k $vg
check_lv_field_ $vg /$lv lv_read_ahead "8.00k"
lvremove -ff $vg
lvcreate -L 32m -n $lv --readahead auto $vg
check_lv_field_ $vg /$lv lv_read_ahead "auto"
lvremove -ff $vg