update heuristic used for default data alignment
PATCH 1/1 update heuristic used for default data alignment
1) --dataalignment or lvm.conf's "devices/data_alignment" is always used
- neither MD nor IO Topology are even consulted
2) take MAX() of determined alignment value and existing pv->pe_align
3) allow lvm.conf's "device/default_data_alignment" to change the default alignment that LVM2 uses: 0==64k, 1==1MB, 2==2MB, etc.
set_pe_align() still looks to use the determined default (based on lvm.conf's default_data_alignment) if the default is a multiple of the MD or topology provided values.
Signed-off-by Mike Snitzer <[email protected]>
--- doc/example.conf.in | 8 ++++++- lib/config/defaults.h | 2 + lib/format_text/format-text.c | 20 ++++++++++------ lib/metadata/metadata.c | 48 ++++++++++++++++++++++++++++------------ 4 files changed, 54 insertions(+), 24 deletions(-)
doc/example.conf.in +7 -1
@@ -98,6 +98,11 @@ devices { # 1 enables; 0 disables. md_chunk_alignment = 1 + # Default alignment of the start of a data area in MB. If set to 0, + # a small value of 64KB will be used, which was the default until + # LVM2 version 2.02.73. Set to 1 for 1MiB, 2 for 2MiB, etc. + default_data_alignment = 1 + # By default, the start of a PV's data area will be a multiple of # the 'minimum_io_size' or 'optimal_io_size' exposed in sysfs. # - minimum_io_size - the smallest request the device can perform
@@ -113,7 +118,8 @@ devices { # Alignment (in KB) of start of data area when creating a new PV. # If a PV is placed directly upon an md device and md_chunk_alignment or # data_alignment_detection is enabled this parameter is ignored. - # Set to 0 for the default alignment of 1MB or page size, if larger. + # Set to 0 for the default alignment (see: data_alignment_default) + # or page size, if larger. data_alignment = 0 # By default, the start of the PV's aligned data area will be shifted by
lib/config/defaults.h +2 -0
@@ -17,6 +17,7 @@#define _LVM_DEFAULTS_H#define DEFAULT_PE_ALIGN 2048 +#define DEFAULT_PE_ALIGN_OLD 128#define DEFAULT_ARCHIVE_ENABLED 1#define DEFAULT_BACKUP_ENABLED 1
@@ -33,6 +34,7 @@#define DEFAULT_MD_CHUNK_ALIGNMENT 1#define DEFAULT_IGNORE_SUSPENDED_DEVICES 1#define DEFAULT_REQUIRE_RESTOREFILE_WITH_UUID 1 +#define DEFAULT_DATA_ALIGNMENT 1#define DEFAULT_DATA_ALIGNMENT_OFFSET_DETECTION 1#define DEFAULT_DATA_ALIGNMENT_DETECTION 1
lib/format_text/format-text.c +12 -8
@@ -1861,16 +1861,20 @@ static int _text_pv_setup(const struct format_type *fmt, 0) * 2;if (set_pe_align (pv, data_alignment) != data_alignment && - data_alignment) -log_warn ("WARNING: %s: Overriding data alignment to " -"%lu sectors (requested %lu sectors)" , -pv_dev_name (pv), pv->pe_align, data_alignment); + data_alignment) { +log_error ("%s: invalid data alignment of " +"%lu sectors (requested %lu sectors)" , +pv_dev_name (pv), pv->pe_align, data_alignment); +return 0 ; + }if (set_pe_align_offset (pv, data_alignment_offset) != data_alignment_offset && - data_alignment_offset) -log_warn ("WARNING: %s: Overriding data alignment offset to " -"%lu sectors (requested %lu sectors)" , -pv_dev_name (pv), pv->pe_align_offset, data_alignment_offset); + data_alignment_offset) { +log_error ("%s: invalid data alignment offset of " +"%lu sectors (requested %lu sectors)" , +pv_dev_name (pv), pv->pe_align_offset, data_alignment_offset); +return 0 ; + }if (pv->pe_align < pv->pe_align_offset) { log_error("%s: pe_align (%lu sectors) must not be less "
lib/metadata/metadata.c +33 -15
100 lines not on this page · raw message