2007-09-22 01:14:25 +04:00
#!/bin/sh
2012-03-16 17:00:05 +04:00
# Copyright (C) 2008-2011 Red Hat, Inc. All rights reserved.
2007-09-22 01:14:25 +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
2008-09-30 21:47:34 +04:00
# 'Check extents percentage arguments'
2007-09-22 01:14:25 +04:00
2014-06-06 19:40:04 +04:00
. lib/inittest
2007-09-22 01:14:25 +04:00
2015-05-09 02:59:18 +03:00
test -e LOCAL_LVMPOLLD && skip
2013-06-15 13:21:03 +04:00
aux prepare_pvs 2 128
vgcreate $vg $( cat DEVICES)
2007-09-22 01:14:25 +04:00
2013-06-15 13:21:03 +04:00
lvcreate -L64 -n $lv $vg
2007-09-22 01:14:25 +04:00
2008-09-30 21:47:34 +04:00
# 'lvextend rejects both size and extents without PVs'
2009-09-30 20:13:53 +04:00
not lvextend -l 10 -L 64m $vg /$lv 2>err
2012-03-16 17:00:05 +04:00
grep "Please specify either size or extents but not both." err
2007-09-22 01:14:25 +04:00
2008-09-30 21:47:34 +04:00
# 'lvextend rejects both size and extents with PVs'
2012-03-16 17:00:05 +04:00
not lvextend -l 10 -L 64m $vg /$lv " $dev1 " 2>err
grep "Please specify either size or extents but not both." err
2007-09-22 01:14:25 +04:00
2008-09-30 21:47:34 +04:00
# 'lvextend accepts no size or extents but one PV - bz154691'
2012-03-16 17:00:05 +04:00
lvextend $vg /$lv " $dev1 " >out
grep " Logical volume $lv successfully resized " out
check pv_field " $dev1 " pv_free "0"
2007-09-22 01:14:25 +04:00
2012-03-16 17:00:05 +04:00
lvremove -f $vg /$lv
2008-11-11 18:46:15 +03:00
# 'lvextend computes necessary free space correctly - bz213552'
2012-03-16 17:00:05 +04:00
vgsize = $( get vg_field $vg vg_extent_count)
2008-11-11 18:46:15 +03:00
lvcreate -l $vgsize -n $lv $vg
2010-02-17 18:41:28 +03:00
lvreduce -f -l $(( $vgsize / 2 )) $vg /$lv
2008-11-11 18:46:15 +03:00
lvextend -l $vgsize $vg /$lv
2012-03-16 17:00:05 +04:00
# 'Reset LV to original size'
lvremove -f $vg /$lv
2009-09-30 20:13:53 +04:00
lvcreate -L 64m -n $lv $vg
2007-09-22 01:14:25 +04:00
2008-09-30 21:47:34 +04:00
# 'lvextend accepts no size but extents 100%PVS and two PVs - bz154691'
2012-03-16 17:00:05 +04:00
lvextend -l +100%PVS $vg /$lv " $dev1 " " $dev2 " >out
grep " Logical volume $lv successfully resized " out
check pv_field " $dev1 " pv_free "0"
check pv_field " $dev2 " pv_free "0"
2007-09-22 01:14:25 +04:00
# Exercise the range overlap code. Allocate every 2 extents.
2007-09-24 23:19:18 +04:00
#
2007-09-22 01:14:25 +04:00
# Physical Extents
2008-01-17 18:56:53 +03:00
# 1 2
2007-09-22 01:14:25 +04:00
#012345678901234567890123
#
#aaXXaaXXaaXXaaXXaaXXaaXX - (a)llocated
#rrrXXXrrrXXXrrrXXXrrrXXX - (r)ange on cmdline
#ooXXXXXXoXXXooXXXXXXoXXX - (o)verlap of range and allocated
#
# Key: a - allocated
# F - free
# r - part of a range on the cmdline
# N - not on cmdline
#
# Create the LV with 12 extents, allocated every other 2 extents.
# Then extend it, with a range of PVs on the cmdline of every other 3 extents.
# Total number of extents should be 12 + overlap = 12 + 6 = 18.
# Thus, total size for the LV should be 18 * 4M = 72M
#
2012-03-16 17:00:05 +04:00
# 'Reset LV to 12 extents, allocate every other 2 extents'
create_pvs = $( for i in $( seq 0 4 20) ; do echo -n " $dev1 : $i - $(( $i + 1 )) " ; done )
2008-09-30 21:47:34 +04:00
lvremove -f $vg /$lv
lvcreate -l 12 -n $lv $vg $create_pvs
2011-01-05 03:16:18 +03:00
check lv_field $vg /$lv lv_size "48.00m"
2007-09-22 01:14:25 +04:00
2012-03-16 17:00:05 +04:00
# 'lvextend with partially allocated PVs and extents 100%PVS with PE ranges'
extend_pvs = $( for i in $( seq 0 6 18) ; do echo -n " $dev1 : $i - $(( $i + 2 )) " ; done )
2008-09-30 21:47:34 +04:00
lvextend -l +100%PVS $vg /$lv $extend_pvs >out
2012-03-16 17:00:05 +04:00
grep " Logical volume $lv successfully resized " out
2011-01-05 03:16:18 +03:00
check lv_field $vg /$lv lv_size "72.00m"
2007-09-22 01:14:25 +04:00
2009-05-11 07:37:34 +04:00
# Simple seg_count validation; initially create the LV with half the # of
# extents (should be 1 lv segment), extend it (should go to 2 segments),
# then reduce (should be back to 1)
# FIXME: test other segment fields such as seg_size, pvseg_start, pvseg_size
lvremove -f $vg /$lv
2012-03-16 17:00:05 +04:00
pe_count = $( get pv_field " $dev1 " pv_pe_count)
2009-05-11 07:37:34 +04:00
pe1 = $(( $pe_count / 2 ))
lvcreate -l $pe1 -n $lv $vg
2012-03-16 17:00:05 +04:00
pesize = $( get lv_field $vg /$lv vg_extent_size --units b --nosuffix)
2009-09-30 20:13:53 +04:00
segsize = $(( $pe1 * $pesize / 1024 / 1024 )) m
2012-03-16 17:00:05 +04:00
check lv_field $vg /$lv seg_count "1"
check lv_field $vg /$lv seg_start "0"
check lv_field $vg /$lv seg_start_pe "0"
2011-01-05 03:16:18 +03:00
#check lv_field $vg/$lv seg_size $segsize
2009-05-11 07:37:34 +04:00
lvextend -l +$(( $pe_count * 1 )) $vg /$lv
2012-03-16 17:00:05 +04:00
check lv_field $vg /$lv seg_count "2"
2009-05-11 07:37:34 +04:00
lvreduce -f -l -$(( $pe_count * 1 )) $vg /$lv
2012-03-16 17:00:05 +04:00
check lv_field $vg /$lv seg_count "1"
2009-05-11 07:37:34 +04:00
2011-06-09 23:34:49 +04:00
# do not reduce to 0 extents
lvremove -f $vg /$lv
lvcreate -i2 -I 64k -l10 -n $lv $vg
lvreduce -f -l1 $vg /$lv
check lv_field $vg /$lv lv_size "8.00m"