2017-07-02 22:38:32 +03:00
#!/usr/bin/env bash
2014-04-10 16:18:59 +04:00
# Copyright (C) 2014 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
2014-04-10 16:18:59 +04:00
test_description = 'Test pvcreate bootloader area support'
2016-02-23 01:13:42 +03:00
SKIP_WITH_LVMLOCKD = 1
2015-10-27 17:10:06 +03:00
SKIP_WITH_LVMPOLLD = 1
2014-04-10 16:18:59 +04:00
2014-06-06 19:40:04 +04:00
. lib/inittest
2014-04-10 16:18:59 +04:00
aux prepare_devs 1
2015-04-08 23:44:16 +03:00
aux lvmconf 'global/suffix=0' 'global/units="b"'
2014-04-10 16:18:59 +04:00
#COMM 'pvcreate sets/aligns bootloader area correctly'
pvcreate --dataalignment 262144b --bootloaderareasize 614400b " $dev1 "
# ba_start must be aligned based on dataalignment
# pe_start starts at next dataalignment multiple
# ba_size is the whole space in between ba_start and pe_start
check pv_field " $dev1 " ba_start "262144"
check pv_field " $dev1 " ba_size "786432"
check pv_field " $dev1 " pe_start "1048576"
#COMM 'pvcreate with booloader area size - test corner cases'
2014-10-07 11:54:47 +04:00
dev_size = $( pvs -o pv_size --noheadings " $dev1 " )
2017-07-06 20:27:04 +03:00
pv_size = $(( dev_size - 1048576 )) # device size - 1m pe_start = area for data
2014-04-10 16:18:59 +04:00
# try to use the whole data area for bootloader area, remaining data area is zero then (pe_start = pv_size)
pvcreate --bootloaderareasize ${ pv_size } b --dataalignment 1048576b " $dev1 "
check pv_field " $dev1 " pe_start $dev_size
check pv_field " $dev1 " ba_start 1048576
check pv_field " $dev1 " ba_size $pv_size
# try to use the whole data area for bootloader area only and add one more byte - this must error out
2017-07-06 20:27:04 +03:00
not pvcreate --bootloaderareasize $(( pv_size + 1 )) --dataalignment 1048576b " $dev1 " 2>err
2014-04-10 16:18:59 +04:00
grep "Bootloader area with data-aligned start must not exceed device size" err
# restoring the PV should also restore the bootloader area correctly
pvremove -ff " $dev1 "
pvcreate --dataalignment 256k --bootloaderareasize 600k " $dev1 "
vgcreate $vg " $dev1 "
2017-07-10 11:40:09 +03:00
vgcfgbackup -f " $TESTDIR /vg_with_ba_backup " " $vg "
2014-04-10 16:18:59 +04:00
pv_uuid = $( get pv_field " $dev1 " pv_uuid)
vgremove -ff $vg
pvremove -ff " $dev1 "
2017-07-10 11:40:09 +03:00
pvcreate --dataalignment 256k --restorefile " $TESTDIR /vg_with_ba_backup " --uuid " $pv_uuid " " $dev1 "
2014-04-10 16:18:59 +04:00
check pv_field " $dev1 " ba_start "262144"
check pv_field " $dev1 " ba_size "786432"
check pv_field " $dev1 " pe_start "1048576"
pvremove -ff " $dev1 "