1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00
lvm2/test/shell/pvcreate-bootloaderarea.sh
David Teigland 904e1e3d26 Place the first PE at 1 MiB for all defaults
. When using default settings, this commit should change
  nothing.  The first PE continues to be placed at 1 MiB
  resulting in a metadata area size of 1020 KiB (for
  4K page sizes; slightly smaller for larger page sizes.)

. When default_data_alignment is disabled in lvm.conf,
  align pe_start at 1 MiB, based on a default metadata area
  size that adapts to the page size.  Previously, disabling
  this option would result in mda_size that was too small
  for common use, and produced a 64 KiB aligned pe_start.

. Customized pe_start and mda_size values continue to be
  set as before in lvm.conf and command line.

. Remove the configure option for setting default_data_alignment
  at build time.

. Improve alignment related option descriptions.

. Add section about alignment to pvcreate man page.

Previously, DEFAULT_PVMETADATASIZE was 255 sectors.
However, the fact that the config setting named
"default_data_alignment" has a default value of 1 (MiB)
meant that DEFAULT_PVMETADATASIZE was having no effect.

The metadata area size is the space between the start of
the metadata area (page size offset from the start of the
device) and the first PE (1 MiB by default due to
default_data_alignment 1.)  The result is a 1020 KiB metadata
area on machines with 4KiB page size (1024 KiB - 4 KiB),
and smaller on machines with larger page size.

If default_data_alignment was set to 0 (disabled), then
DEFAULT_PVMETADATASIZE 255 would take effect, and produce a
metadata area that was 188 KiB and pe_start of 192 KiB.
This was too small for common use.

This is fixed by making the default metadata area size a
computed value that matches the value produced by
default_data_alignment.
2018-11-26 16:36:50 -06:00

59 lines
2.4 KiB
Bash

#!/usr/bin/env bash
# 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,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
test_description='Test pvcreate bootloader area support'
SKIP_WITH_LVMPOLLD=1
. lib/inittest
aux prepare_devs 1
aux lvmconf 'global/suffix=0' 'global/units="b"'
#COMM 'pvcreate sets/aligns bootloader area correctly'
pvcreate --metadatasize 255s --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'
dev_size=$(pvs -o pv_size --noheadings "$dev1")
pv_size=$(( dev_size - 1048576 )) # device size - 1m pe_start = area for data
# try to use the whole data area for bootloader area, remaining data area is zero then (pe_start = pv_size)
pvcreate --metadatasize 255s --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
not pvcreate --bootloaderareasize $(( pv_size + 1 )) --dataalignment 1048576b "$dev1" 2>err
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 --metadatasize 255s --dataalignment 256k --bootloaderareasize 600k "$dev1"
vgcreate $SHARED $vg "$dev1"
vgcfgbackup -f "$TESTDIR/vg_with_ba_backup" "$vg"
pv_uuid=$(get pv_field "$dev1" pv_uuid)
vgremove -ff $vg
pvremove -ff "$dev1"
pvcreate --metadatasize 255s --dataalignment 256k --restorefile "$TESTDIR/vg_with_ba_backup" --uuid "$pv_uuid" "$dev1"
check pv_field "$dev1" ba_start "262144"
check pv_field "$dev1" ba_size "786432"
check pv_field "$dev1" pe_start "1048576"
pvremove -ff "$dev1"