1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-22 17:35:59 +03:00
lvm2/test/shell/pe-align.sh

145 lines
5.1 KiB
Bash
Raw Normal View History

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-14 00:00:11 +03:00
#!/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 pe alignment and metadata sizes'
SKIP_WITH_LVMPOLLD=1
. lib/inittest
aux prepare_devs 1
# values depend on page size 4K
# In order of strength:
# --dataalignmentoffset (modifies all below)
# --dataalignment (overrides all below)
# devices/data_alignment (overrides all below)
# devices/data_alignment_offset_detection (overrides all below)
# devices/md_chunk_alignment (overrides all below)
# devices/default_data_alignment
pvcreate "$dev1"
check pv_field "$dev1" pe_start 1.00m
check pv_field "$dev1" mda_size 1020.00k
pvremove "$dev1"
# default align at 1m is effective even with smaller requested metadata
pvcreate --metadatasize 100k "$dev1"
check pv_field "$dev1" pe_start 1.00m
check pv_field "$dev1" mda_size 1020.00k
pvremove "$dev1"
# default first pe doesn't depend on on these two settings
pvcreate --config 'devices {default_data_alignment=0 data_alignment=0}' "$dev1"
check pv_field "$dev1" pe_start 1.00m
check pv_field "$dev1" mda_size 1020.00k
pvremove "$dev1"
# same as previous
pvcreate --config 'devices {default_data_alignment=1 data_alignment=0}' "$dev1"
check pv_field "$dev1" pe_start 1.00m
check pv_field "$dev1" mda_size 1020.00k
pvremove "$dev1"
# same as previous
pvcreate --config 'devices {default_data_alignment=0 data_alignment=1024}' "$dev1"
check pv_field "$dev1" pe_start 1.00m
check pv_field "$dev1" mda_size 1020.00k
pvremove "$dev1"
# same as previous
pvcreate --config 'devices {default_data_alignment=1 data_alignment=1024}' "$dev1"
check pv_field "$dev1" pe_start 1.00m
check pv_field "$dev1" mda_size 1020.00k
pvremove "$dev1"
# combine above
pvcreate --metadatasize 100k --config 'devices {default_data_alignment=0 data_alignment=0}' "$dev1"
check pv_field "$dev1" pe_start 1.00m
check pv_field "$dev1" mda_size 1020.00k
pvremove "$dev1"
pvcreate --metadatasize 2048k "$dev1"
check pv_field "$dev1" pe_start 3072.00k --units k
check pv_field "$dev1" mda_size 3068.00k --units k
pvremove "$dev1"
pvcreate --metadatasize 2044k "$dev1"
check pv_field "$dev1" pe_start 2048.00k --units k
check pv_field "$dev1" mda_size 2044.00k --units k
pvremove "$dev1"
pvcreate --metadatasize 2048k --config 'devices {default_data_alignment=2}' "$dev1"
check pv_field "$dev1" pe_start 4.00m
check pv_field "$dev1" mda_size 4092.00k --units k
pvremove "$dev1"
pvcreate --metadatasize 100k --config 'devices {default_data_alignment=2}' "$dev1"
check pv_field "$dev1" pe_start 2048.00k --units k
check pv_field "$dev1" mda_size 2044.00k --units k
pvremove "$dev1"
pvcreate --metadatasize 2048k --dataalignment 128k "$dev1"
check pv_field "$dev1" pe_start 2176.00k --units k
check pv_field "$dev1" mda_size 2172.00k --units k
pvremove "$dev1"
pvcreate --metadatasize 2048k --dataalignment 128k --dataalignmentoffset 2k "$dev1"
check pv_field "$dev1" pe_start 2178.00k --units k
check pv_field "$dev1" mda_size 2174.00k --units k
pvremove "$dev1"
pvcreate --metadatasize 2048k --dataalignment 128k --config 'devices {default_data_alignment=0}' "$dev1"
check pv_field "$dev1" pe_start 2176.00k --units k
check pv_field "$dev1" mda_size 2172.00k --units k
pvremove "$dev1"
pvcreate --metadatasize 2048k --dataalignment 128k --config 'devices {default_data_alignment=2}' "$dev1"
check pv_field "$dev1" pe_start 2176.00k --units k
check pv_field "$dev1" mda_size 2172.00k --units k
pvremove "$dev1"
pvcreate --metadatasize 2048k --config 'devices {default_data_alignment=2 data_alignment=128}' "$dev1"
check pv_field "$dev1" pe_start 2176.00k --units k
check pv_field "$dev1" mda_size 2172.00k --units k
pvremove "$dev1"
pvcreate --bootloaderareasize 256k "$dev1"
check pv_field "$dev1" mda_size 1020.00k --units k
check pv_field "$dev1" ba_start 1024.00k --units k
check pv_field "$dev1" ba_size 1024.00k --units k
check pv_field "$dev1" pe_start 2048.00k --units k
pvremove "$dev1"
pvcreate --dataalignment 128k --bootloaderareasize 256k "$dev1"
check pv_field "$dev1" mda_size 1020.00k --units k
check pv_field "$dev1" ba_start 1024.00k --units k
check pv_field "$dev1" ba_size 256.00k --units k
check pv_field "$dev1" pe_start 1280.00k --units k
pvremove "$dev1"
pvcreate --dataalignment 128k --metadatasize 256k "$dev1"
check pv_field "$dev1" mda_size 380.00k --units k
check pv_field "$dev1" ba_start 0k --units k
check pv_field "$dev1" ba_size 0k --units k
check pv_field "$dev1" pe_start 384.00k --units k
pvremove "$dev1"
pvcreate --dataalignment 128k --metadatasize 256k --bootloaderareasize 256k "$dev1"
check pv_field "$dev1" mda_size 380.00k --units k
check pv_field "$dev1" ba_start 384.00k --units k
check pv_field "$dev1" ba_size 256.00k --units k
check pv_field "$dev1" pe_start 640.00k --units k
pvremove "$dev1"