LVM2 topology support
cover LVM2 topology support
LVM2 topology support to properly align the PV's pe_start using the associated 'alignment_offset' exposed in sysfs.
Provides manual configuration with pvcreate --dataalignmentoffset and auto config control via 'devices/data_alignment_offset_detection' in lvm.conf
Documentation was added to the lvm.conf and pvcreate man pages.
Testing with pvcreate + vgextend + vgreduce + vgextend + vgreduce ... proved to maintain the pe_start from the initial pvcreate.
Mike Snitzer (3):
cmdline: support for bytes and sectors
pvcreate: --dataalignmentoffset
Add devices/data_alignment_offset_detection to lvm.conf.
WHATS_NEW | 3 ++ doc/example.conf | 5 +++ lib/config/defaults.h | 1 + lib/device/device.c | 60 ++++++++++++++++++++++++++++++++++++++ lib/device/device.h | 3 ++ lib/format1/format1.c | 1 + lib/format_pool/format_pool.c | 1 + lib/format_text/archiver.c | 2 +- lib/format_text/format-text.c | 33 +++++++++++++++++++-- lib/metadata/metadata-exported.h | 1 + lib/metadata/metadata.c | 10 +++++- lib/metadata/metadata.h | 1 + man/lvm.conf.5.in | 8 ++++- man/pvcreate.8.in | 18 ++++++++++- tools/args.h | 1 + tools/commands.h | 33 +++++++++++---------- tools/lvmcmdline.c | 20 +++++++++---- tools/pvcreate.c | 23 +++++++++++++- tools/vgconvert.c | 2 +- 19 files changed, 192 insertions(+), 34 deletions(-)
cover LVM2 topology support
pvcreate --dataalignmentoffset support and configuration via devices/data_alignment_offset_detection.
Documentation was added to the lvm.conf and pvcreate man pages.
Testing with pvcreate + vgextend + vgreduce + vgextend + vgreduce ... proved to maintain the pe_start from the original pvcreate.
Mike Snitzer (3):
cmdline: support for bytes and sectors
pvcreate: --dataalignmentoffset
Add devices/data_alignment_offset_detection to lvm.conf.
WHATS_NEW | 3 ++ doc/example.conf | 5 +++ lib/config/defaults.h | 1 + lib/device/device.c | 60 ++++++++++++++++++++++++++++++++++++++ lib/device/device.h | 3 ++ lib/format1/format1.c | 1 + lib/format_pool/format_pool.c | 1 + lib/format_text/archiver.c | 2 +- lib/format_text/format-text.c | 33 +++++++++++++++++++-- lib/metadata/metadata-exported.h | 1 + lib/metadata/metadata.c | 10 +++++- lib/metadata/metadata.h | 1 + man/lvm.conf.5.in | 8 ++++- man/pvcreate.8.in | 18 ++++++++++- tools/args.h | 1 + tools/commands.h | 33 +++++++++++---------- tools/lvmcmdline.c | 20 +++++++++---- tools/pvcreate.c | 23 +++++++++++++- tools/vgconvert.c | 2 +- 19 files changed, 192 insertions(+), 34 deletions(-)
PATCH 1/3 cmdline: support for bytes and sectors
In reply to Mike SnitzerAllow specifying commandline sizes in terms of bytes and sectors.
--- WHATS_NEW | 1 + tools/commands.h | 26 +++++++++++++------------- tools/lvmcmdline.c | 20 ++++++++++++++------ 3 files changed, 28 insertions(+), 19 deletions(-)
WHATS_NEW +1 -0
@@ -1,5 +1,6 @@ Version 2.02.48 - =============================== + Allow specifying commandline sizes in terms of bytes and sectors. Round up requested readahead to at least one page and print warning. Try to repair vg before actual vgremove when force flag provided. Fix possible double release of VG after recovery.
tools/commands.h +13 -13
@@ -19,7 +19,7 @@ xx(e2fsadm,"e2fsadm " "[-d|--debug] " "[-h|--help] " "[-n|--nofsck]" "\n" "\t{[-l|--extents] [+|-]LogicalExtentsNumber |" "\n" -"\t [-L|--size] [+|-]LogicalVolumeSize[kKmMgGtTpPeE]}" "\n" +"\t [-L|--size] [+|-]LogicalVolumeSize[sSbBkKmMgGtTpPeE]}" "\n" "\t[-t|--test] " "\n" "\t[-v|--verbose] " "\n" "\t[--version] " "\n"
@@ -131,7 +131,7 @@ xx(lvcreate,"\t[-h|-?|--help]\n" "\t[-i|--stripes Stripes [-I|--stripesize StripeSize]]\n" "\t{-l|--extents LogicalExtentsNumber |\n" -"\t -L|--size LogicalVolumeSize[kKmMgGtTpPeE]}\n" +"\t -L|--size LogicalVolumeSize[sSbBkKmMgGtTpPeE]}\n" "\t[-M|--persistent {y|n}] [--major major] [--minor minor]\n" "\t[-m|--mirrors Mirrors [--nosync] [{--mirrorlog {disk|core}|--corelog}]]\n" "\t[-n|--name LogicalVolumeName]\n"
@@ -157,7 +157,7 @@ xx(lvcreate,"\t[-h|-?|--help]\n" "\t[-i|--stripes Stripes [-I|--stripesize StripeSize]]\n" "\t{-l|--extents LogicalExtentsNumber[%{VG|LV|PVS|FREE}] |\n" -"\t -L|--size LogicalVolumeSize[kKmMgGtTpPeE]}\n" +"\t -L|--size LogicalVolumeSize[sSbBkKmMgGtTpPeE]}\n" "\t[-M|--persistent {y|n}] [--major major] [--minor minor]\n" "\t[-n|--name LogicalVolumeName]\n" "\t[-p|--permission {r|rw}]\n"
@@ -226,7 +226,7 @@ xx(lvextend,"\t[-h|--help]\n" "\t[-i|--stripes Stripes [-I|--stripesize StripeSize]]\n" "\t{-l|--extents [+]LogicalExtentsNumber[%{VG|PVS|FREE}] |\n" -"\t -L|--size [+]LogicalVolumeSize[kKmMgGtTpPeE]}\n" +"\t -L|--size [+]LogicalVolumeSize[sSbBkKmMgGtTpPeE]}\n" "\t[-m|--mirrors Mirrors]\n" "\t[-n|--nofsck]\n" "\t[-r|--resizefs]\n"
@@ -296,7 +296,7 @@ xx(lvreduce,"\t[-f|--force]\n" "\t[-h|--help]\n" "\t{-l|--extents [-]LogicalExtentsNumber[%{VG|LV|FREE}] |\n" -"\t -L|--size [-]LogicalVolumeSize[kKmMgGtTpPeE]}\n" +"\t -L|--size [-]LogicalVolumeSize[sSbBkKmMgGtTpPeE]}\n" "\t[-n|--nofsck]\n" "\t[-r|--resizefs]\n" "\t[-t|--test]\n"
@@ -349,7 +349,7 @@ xx(lvresize,"\t[-h|--help]\n" "\t[-i|--stripes Stripes [-I|--stripesize StripeSize]]\n" "\t{-l|--extents [+|-]LogicalExtentsNumber[%{VG|LV|PVS|FREE}] |\n" -"\t -L|--size [+|-]LogicalVolumeSize[kKmMgGtTpPeE]}\n" +"\t -L|--size [+|-]LogicalVolumeSize[sSbBkKmMgGtTpPeE]}\n" "\t[-n|--nofsck]\n" "\t[-r|--resizefs]\n" "\t[-t|--test]\n"
@@ -434,7 +434,7 @@ xx(pvresize,"pvresize " "\n" "\t[-d|--debug]" "\n" "\t[-h|-?|--help] " "\n" -"\t[--setphysicalvolumesize PhysicalVolumeSize[kKmMgGtTpPeE]" "\n" +"\t[--setphysicalvolumesize PhysicalVolumeSize[sSbBkKmMgGtTpPeE]" "\n" "\t[-t|--test] " "\n" "\t[-v|--verbose] " "\n" "\t[--version] " "\n"
@@ -466,9 +466,9 @@ xx(pvcreate,"\t[--labelsector sector] " "\n" "\t[-M|--metadatatype 1|2]" "\n" "\t[--metadatacopies #copies]" "\n" -"\t[--metadatasize MetadataSize[kKmMgGtTpPeE]]" "\n" -"\t[--dataalignment Alignment[kKmMgGtTpPeE]]" "\n" -"\t[--setphysicalvolumesize PhysicalVolumeSize[kKmMgGtTpPeE]" "\n" +"\t[--metadatasize MetadataSize[sSbBkKmMgGtTpPeE]]" "\n" +"\t[--dataalignment Alignment[sSbBkKmMgGtTpPeE]]" "\n" +"\t[--setphysicalvolumesize PhysicalVolumeSize[sSbBkKmMgGtTpPeE]" "\n" "\t[-t|--test] " "\n" "\t[-u|--uuid uuid] " "\n" "\t[-v|--verbose] " "\n"
@@ -681,7 +681,7 @@ xx(vgchange,"\t -x|--resizeable {y|n} |" "\n" "\t -l|--logicalvolume MaxLogicalVolumes |" "\n" "\t -p|--maxphysicalvolumes MaxPhysicalVolumes |" "\n" -"\t -s|--physicalextentsize PhysicalExtentSize[kKmMgGtTpPeE] |" "\n" +"\t -s|--physicalextentsize PhysicalExtentSize[sSbBkKmMgGtTpPeE] |" "\n" "\t --addtag Tag |\n" "\t --deltag Tag}\n" "\t[VolumeGroupName...]\n",
@@ -711,7 +711,7 @@ xx(vgconvert,"\t[--labelsector sector] " "\n" "\t[-M|--metadatatype 1|2]" "\n" "\t[--metadatacopies #copies]" "\n" -"\t[--metadatasize MetadataSize[kKmMgGtTpPeE]]" "\n" +"\t[--metadatasize MetadataSize[sSbBkKmMgGtTpPeE]]" "\n" "\t[-t|--test] " "\n" "\t[-v|--verbose] " "\n" "\t[--version] " "\n"
@@ -733,7 +733,7 @@ xx(vgcreate,"\t[-l|--maxlogicalvolumes MaxLogicalVolumes]" "\n" "\t[-M|--metadatatype 1|2] " "\n" "\t[-p|--maxphysicalvolumes MaxPhysicalVolumes] " "\n" -"\t[-s|--physicalextentsize PhysicalExtentSize[kKmMgGtTpPeE]] " "\n" +"\t[-s|--physicalextentsize PhysicalExtentSize[sSbBkKmMgGtTpPeE]] " "\n" "\t[-t|--test] " "\n" "\t[-v|--verbose]" "\n" "\t[--version] " "\n"
tools/lvmcmdline.c +14 -6
@@ -239,7 +239,7 @@ static int _size_arg(struct cmd_context *cmd __attribute((unused)), struct arg * {char *ptr;int i; -static const char *suffixes ="kmgtpe" ; +static const char *suffixes ="kmgtpebs" ;char *val;double v;
@@ -274,11 +274,19 @@ static int _size_arg(struct cmd_context *cmd __attribute((unused)), struct arg *if (i <0 )return 0 ; - -while (i-- >0 ) - v *=1024 ; - - v *=2 ; +else if (i ==7 ) { +/* sectors */ + v = v; + }else if (i ==6 ) { +/* bytes */ +if (v <512 ) +return 0 ; + v /=512 ; + }else { +while (i-- >0 ) + v *=1024 ; + v *=2 ; + } }else v *= factor;
Signature · 1 line
1.6.2.2
PATCH 2/3 pvcreate: --dataalignmentoffset
In reply to Mike SnitzerImplement pvcreate --dataalignmentoffset to pad offset of the start of the aligned data area (pe_start).
Mike Snitzer <[email protected]>
--- WHATS_NEW | 1 + lib/format1/format1.c | 1 + lib/format_pool/format_pool.c | 1 + lib/format_text/archiver.c | 2 +- lib/format_text/format-text.c | 24 +++++++++++++++++++++--- lib/metadata/metadata-exported.h | 1 + lib/metadata/metadata.c | 10 ++++++++-- lib/metadata/metadata.h | 1 + man/pvcreate.8.in | 18 ++++++++++++++++-- tools/args.h | 1 + tools/commands.h | 7 ++++--- tools/pvcreate.c | 23 +++++++++++++++++++++-- tools/vgconvert.c | 2 +- 13 files changed, 78 insertions(+), 14 deletions(-)
WHATS_NEW +1 -0
@@ -1,5 +1,6 @@ Version 2.02.48 - =============================== + Implement pvcreate --dataalignmentoffset to pad offset of pe_start. Allow specifying commandline sizes in terms of bytes and sectors. Round up requested readahead to at least one page and print warning. Try to repair vg before actual vgremove when force flag provided.
lib/format1/format1.c +1 -0
@@ -296,6 +296,7 @@ static int _format1_pv_setup(const struct format_type *fmt, uint64_t pe_start, uint32_t extent_count, uint32_t extent_size, unsigned long data_alignment __attribute((unused)), + unsigned long data_alignment_offset __attribute((unused)), int pvmetadatacopies __attribute((unused)), uint64_t pvmetadatasize __attribute((unused)), struct dm_list *mdas __attribute((unused)), struct physical_volume *pv, struct volume_group *vg __attribute((unused)))
lib/format_pool/format_pool.c +1 -0
@@ -192,6 +192,7 @@ static int _pool_pv_setup(const struct format_type *fmt __attribute((unused)), uint32_t extent_count __attribute((unused)), uint32_t extent_size __attribute((unused)), unsigned long data_alignment __attribute((unused)), + unsigned long data_alignment_offset __attribute((unused)), int pvmetadatacopies __attribute((unused)), uint64_t pvmetadatasize __attribute((unused)), struct dm_list *mdas __attribute((unused)),
lib/format_text/archiver.c +1 -1
@@ -316,7 +316,7 @@ int backup_restore_vg(struct cmd_context *cmd, struct volume_group *vg)return 0 ; }if (!vg->fid->fmt->ops-> -pv_setup (vg->fid->fmt,UINT64_C (0 ),0 ,0 ,0 ,0UL , +pv_setup (vg->fid->fmt,UINT64_C (0 ),0 ,0 ,0 ,0 ,0UL ,UINT64_C (0 ), &vg->fid->metadata_areas, pv, vg)) {log_error ("Format-specific setup for %s failed" ,pv_dev_name (pv));
lib/format_text/format-text.c +21 -3
@@ -1175,12 +1175,13 @@ static int _text_scan(const struct format_type *fmt)Always have an mda between end-of-label and pe_align() boundary */ static int _mda_setup (const struct format_type *fmt,uint64_t pe_start,uint64_t pe_end, +unsigned long data_alignment_offset,int pvmetadatacopies,uint64_t pvmetadatasize,struct dm_list *mdas,struct physical_volume *pv,struct volume_group *vg __attribute((unused))) { -uint64_t mda_adjustment, disk_size, alignment; +uint64_t mda_adjustment, adjustment, disk_size, alignment;uint64_t start1, mda_size1;/* First area - start of disk */ uint64_t start2, mda_size2;/* Second area - end of disk */ uint64_t wipe_size =8 <<SECTOR_SHIFT ;
@@ -1251,6 +1252,22 @@ static int _mda_setup(const struct format_type *fmt,return 0 ; } +if (!pe_start && !pe_end) { +/* +* proactively adjust pv->pe_start to allow for +* proper padding with data_alignment_offset +* - _text_pv_write is too late given the lack of info +*/ + pv->pe_start = (start1 + mda_size1) >>SECTOR_SHIFT ; +/* round up to pe_align boundry */ + adjustment = pv->pe_start % pv->pe_align; +if (adjustment) + pv->pe_start += (pv->pe_align - adjustment); + +if (data_alignment_offset) + pv->pe_start += data_alignment_offset; + } +if (pvmetadatacopies ==1 )return 1 ; }else
@@ -1598,6 +1615,7 @@ static struct metadata_area_ops _metadata_text_raw_ops = {static int _text_pv_setup (const struct format_type *fmt,uint64_t pe_start,uint32_t extent_count,uint32_t extent_size,unsigned long data_alignment, +unsigned long data_alignment_offset,int pvmetadatacopies,uint64_t pvmetadatasize,struct dm_list *mdas,struct physical_volume *pv,struct volume_group *vg)
@@ -1707,8 +1725,8 @@ static int _text_pv_setup(const struct format_type *fmt,if (extent_count) pe_end = pe_start + extent_count * extent_size -1 ; -if (!_mda_setup (fmt, pe_start, pe_end, pvmetadatacopies, - pvmetadatasize, mdas, pv, vg)) +if (!_mda_setup (fmt, pe_start, pe_end, data_alignment_offset, + pvmetadatacopies, pvmetadatasize, mdas, pv, vg)) return_0; }
lib/metadata/metadata-exported.h +1 -0
@@ -423,6 +423,7 @@ pv_t *pv_create(const struct cmd_context *cmd,struct id *id, uint64_t size, unsigned long data_alignment, + unsigned long data_alignment_offset, uint64_t pe_start, uint32_t existing_extent_count, uint32_t existing_extent_size,
lib/metadata/metadata.c +8 -2
@@ -48,6 +48,7 @@ static struct physical_volume *_pv_create(const struct format_type *fmt,struct device *dev, struct id *id, uint64_t size, unsigned long data_alignment, + unsigned long data_alignment_offset, uint64_t pe_start, uint32_t existing_extent_count, uint32_t existing_extent_size,
@@ -157,7 +158,7 @@ int add_pv_to_vg(struct volume_group *vg, const char *pv_name, pv->pe_alloc_count =0 ;if (!fid->fmt->ops->pv_setup (fid->fmt,UINT64_C (0 ),0 , - vg->extent_size,0 ,0UL ,UINT64_C (0 ), + vg->extent_size,0 ,0 ,0UL ,UINT64_C (0 ), &fid->metadata_areas, pv, vg)) {log_error ("Format-specific setup of physical volume '%s' " "failed." , pv_name);
@@ -787,6 +788,7 @@ int vg_split_mdas(struct cmd_context *cmd __attribute((unused)),* @id: PV UUID to use for initialization * @size: size of the PV in sectors * @data_alignment: requested alignment of data +* @data_alignment_offset: requested offset to aligned data * @pe_start: physical extent start * @existing_extent_count * @existing_extent_size
@@ -805,13 +807,15 @@ pv_t *pv_create(const struct cmd_context *cmd, struct device *dev, struct id *id, uint64_t size, unsigned long data_alignment, + unsigned long data_alignment_offset, uint64_t pe_start, uint32_t existing_extent_count, uint32_t existing_extent_size, int pvmetadatacopies, uint64_t pvmetadatasize, struct dm_list *mdas) { - return _pv_create(cmd->fmt, dev, id, size, data_alignment, pe_start, + return _pv_create(cmd->fmt, dev, id, size, + data_alignment, data_alignment_offset, pe_start, existing_extent_count, existing_extent_size, pvmetadatacopies,
@@ -856,6 +860,7 @@ static struct physical_volume *_pv_create(const struct format_type *fmt,struct device *dev, struct id *id, uint64_t size, unsigned long data_alignment, + unsigned long data_alignment_offset, uint64_t pe_start, uint32_t existing_extent_count, uint32_t existing_extent_size,
@@ -907,6 +912,7 @@ static struct physical_volume *_pv_create(const struct format_type *fmt,if (!fmt->ops->pv_setup (fmt, pe_start, existing_extent_count, existing_extent_size, data_alignment, + data_alignment_offset, pvmetadatacopies, pvmetadatasize, mdas, pv,NULL )) { log_error("%s: Format-specific setup of physical volume "
lib/metadata/metadata.h +1 -0
@@ -213,6 +213,7 @@ struct format_handler {int (*pv_setup) (const struct format_type * fmt,uint64_t pe_start,uint32_t extent_count,uint32_t extent_size,unsigned long data_alignment, +unsigned long data_alignment_offset,int pvmetadatacopies,uint64_t pvmetadatasize,struct dm_list * mdas,struct physical_volume * pv,struct volume_group * vg);
man/pvcreate.8.in +16 -2
@@ -14,6 +14,7 @@ pvcreate \- initialize a disk or partition for use by LVM .RB [ \-\-metadatacopies #copies ] .RB [ \-\-metadatasize size ] .RB [ \-\-dataalignment alignment ] +.RB [ \-\-dataalignmentoffset offset ] .RB [ \-\-restorefile file ] .RB [ \-\-setphysicalvolumesize size ] .RB [ \-u | \-\-uuid uuid ]
@@ -97,7 +98,12 @@ the Volume Group with \fBvgcreate\fP. .sp To see the location of the first Physical Extent of an existing Physical Volume use \fBpvs -o +pe_start\fP . It will be a multiple of the requested -\fBdata_alignment\fP. +\fBalignment\fP plus the \fBalignment_offset\fP from +\fBdata_alignment_offset_detection\fP (if enabled in \fBlvm.conf\fP) or +\fB--dataalignmentoffset\fP. +.TP +.BR \-\-dataalignmentoffset " alignment_offset" +The offset of the start of the aligned data area will include \fBalignment_offset\fP. .TP .BR \-\-metadatacopies " copies" The number of metadata areas to set aside on each PV. Currently
@@ -128,13 +134,21 @@ in the source). Use with care. .TP .BR \-\-setphysicalvolumesize " size" Overrides the automatically-detected size of the PV. Use with care. -.SH Example +.SH EXAMPLES Initialize partition #4 on the third SCSI disk and the entire fifth SCSI disk for later use by LVM: .sp .B pvcreate /dev/sdc4 /dev/sde .sp +If the 2nd SCSI disk is a 4KB sector drive that compensates for windows +partitioning (sector 7 is the lowest aligned logical block, the 4KB +sectors start at LBA -1, and consequently sector 63 is aligned on a 4KB +boundary) manually account for this when initializing for use by LVM: +.sp +.B pvcreate --dataalignmentoffset 7S /dev/sdb +.sp .SH SEE ALSO +.BR lvm.conf (5), .BR lvm (8), .BR vgcreate (8), .BR vgextend (8),
tools/args.h +1 -0
@@ -59,6 +59,7 @@ arg(nameprefixes_ARG, '\0', "nameprefixes", NULL, 0) arg(unquoted_ARG, '\0', "unquoted", NULL, 0) arg(rows_ARG, '\0', "rows", NULL, 0) arg(dataalignment_ARG, '\0', "dataalignment", size_kb_arg, 0) +arg(dataalignmentoffset_ARG, '\0', "dataalignmentoffset", size_kb_arg, 0) arg(virtualoriginsize_ARG, '\0', "virtualoriginsize", size_mb_arg, 0)arg (virtualsize_ARG,'\0' ,"virtualsize" , size_mb_arg,0 )
tools/commands.h +4 -3
@@ -468,6 +468,7 @@ xx(pvcreate,"\t[--metadatacopies #copies]" "\n" "\t[--metadatasize MetadataSize[sSbBkKmMgGtTpPeE]]" "\n" "\t[--dataalignment Alignment[sSbBkKmMgGtTpPeE]]" "\n" +"\t[--dataalignmentoffset AlignmentOffset[sSbBkKmMgGtTpPeE]]" "\n" "\t[--setphysicalvolumesize PhysicalVolumeSize[sSbBkKmMgGtTpPeE]" "\n" "\t[-t|--test] " "\n" "\t[-u|--uuid uuid] " "\n"
@@ -477,9 +478,9 @@ xx(pvcreate, "\t[--version] " "\n" "\tPhysicalVolume [PhysicalVolume...]\n", - dataalignment_ARG, force_ARG, test_ARG, labelsector_ARG, metadatatype_ARG, - metadatacopies_ARG, metadatasize_ARG, physicalvolumesize_ARG, - restorefile_ARG, uuidstr_ARG, yes_ARG, zero_ARG) + dataalignment_ARG, dataalignmentoffset_ARG, force_ARG, test_ARG, + labelsector_ARG, metadatatype_ARG, metadatacopies_ARG, metadatasize_ARG, + physicalvolumesize_ARG, restorefile_ARG, uuidstr_ARG, yes_ARG, zero_ARG) xx(pvdata, "Display the on-disk metadata for physical volume(s)",
tools/pvcreate.c +21 -2
@@ -20,6 +20,7 @@ struct pvcreate_params {int zero;uint64_t size;uint64_t data_alignment; +uint64_t data_alignment_offset;int pvmetadatacopies;uint64_t pvmetadatasize;int64_t labelsector;
@@ -203,8 +204,8 @@ static int pvcreate_single(struct cmd_context *cmd, const char *pv_name,dm_list_init (&mdas);if (!(pv =pv_create (cmd, dev, pp->idp, pp->size, - pp->data_alignment, pp->pe_start, - pp->extent_count, pp->extent_size, + pp->data_alignment, pp->data_alignment_offset, + pp->pe_start, pp->extent_count, pp->extent_size, pp->pvmetadatacopies, pp->pvmetadatasize,&mdas))) {log_error ("Failed to setup physical volume \"%s\"" , pv_name);
@@ -377,6 +378,24 @@ static int pvcreate_validate_params(struct cmd_context *cmd, pp->data_alignment =0 ; } +if (arg_sign_value (cmd, dataalignmentoffset_ARG,0 ) ==SIGN_MINUS ) { +log_error ("Physical volume data alignment offset may not be negative" ); +return 0 ; + } + pp->data_alignment_offset =arg_uint64_value (cmd, dataalignmentoffset_ARG,UINT64_C (0 )); + +if (pp->data_alignment_offset >ULONG_MAX ) { +log_error ("Physical volume data alignment offset is too big." ); +return 0 ; + } + +if (pp->data_alignment_offset && pp->pe_start) { +log_warn ("WARNING: Ignoring data alignment offset %" PRIu64 +" incompatible with --restorefile value (%" + PRIu64")." , pp->data_alignment_offset, pp->pe_start); + pp->data_alignment_offset =0 ; + } +if (arg_sign_value (cmd, metadatasize_ARG,0 ) ==SIGN_MINUS ) {log_error ("Metadata size may not be negative" );return 0 ;
tools/vgconvert.c +1 -1
@@ -120,7 +120,7 @@ static int vgconvert_single(struct cmd_context *cmd, const char *vg_name,dm_list_init (&mdas);if (!(pv =pv_create (cmd,pv_dev (existing_pv), - &existing_pv->id, size,0 , + &existing_pv->id, size,0 ,0 , pe_start,pv_pe_count (existing_pv),pv_pe_size (existing_pv), pvmetadatacopies, pvmetadatasize, &mdas))) {
Signature · 1 line
1.6.2.2
PATCH 3/3 Add devices/data_alignment_offset_detection to lvm.conf.
In reply to Mike SnitzerIf the pvcreate --dataalignmentoffset option is not specified the offset of the start of a PV's aligned data area will be padded with the associated 'alignment_offset' exposed in sysfs (unless devices/data_alignment_offset_detection is disabled in lvm.conf).
--- WHATS_NEW | 1 + doc/example.conf | 5 +++ lib/config/defaults.h | 1 + lib/device/device.c | 60 +++++++++++++++++++++++++++++++++++++++++ lib/device/device.h | 3 ++ lib/format_text/format-text.c | 9 ++++++ man/lvm.conf.5.in | 8 +++++- 7 files changed, 86 insertions(+), 1 deletions(-)
WHATS_NEW +1 -0
@@ -1,5 +1,6 @@ Version 2.02.48 - =============================== + Add devices/data_alignment_offset_detection to lvm.conf. Implement pvcreate --dataalignmentoffset to pad offset of pe_start. Allow specifying commandline sizes in terms of bytes and sectors. Round up requested readahead to at least one page and print warning.
doc/example.conf +5 -0
@@ -104,6 +104,11 @@ devices { # Set to 0 for the default alignment of 64KB or page size, if larger. data_alignment = 0 + # By default, the offset of the start of a PV's aligned data area + # will be padded with the 'alignment_offset' exposed in sysfs. + # 1 enables; 0 disables. + data_alignment_offset_detection = 1 + # If, while scanning the system for PVs, LVM2 encounters a device-mapper # device that has its I/O suspended, it waits for it to become accessible. # Set this to 1 to skip such devices. This should only be needed
lib/config/defaults.h +1 -0
@@ -34,6 +34,7 @@#define DEFAULT_MD_COMPONENT_DETECTION 1#define DEFAULT_MD_CHUNK_ALIGNMENT 1#define DEFAULT_IGNORE_SUSPENDED_DEVICES 1 +#define DEFAULT_DATA_ALIGNMENT_OFFSET_DETECTION 1#define DEFAULT_LOCK_DIR "/var/lock/lvm"#define DEFAULT_LOCKING_LIB "liblvm2clusterlock.so"
lib/device/device.c +60 -0
63 lines not on this page · raw message
lib/device/device.h +3 -0
@@ -100,4 +100,7 @@ unsigned long dev_md_chunk_size(const char *sysfs_dir, struct device *dev);int is_partitioned_dev (struct device *dev); +unsigned long dev_data_alignment_offset (const char *sysfs_dir, +struct device *dev); +#endif
lib/format_text/format-text.c +9 -0
@@ -29,6 +29,7 @@#include "label.h" #include "memlock.h" #include "lvmcache.h" +#include "defaults.h" #include <unistd.h> #include <sys/file.h>
@@ -1720,6 +1721,14 @@ static int _text_pv_setup(const struct format_type *fmt,"%lu sectors (requested %lu sectors)" , pv_dev_name(pv), pv->pe_align, data_alignment); +if (!pe_start && !data_alignment_offset && +find_config_tree_bool (pv->fmt->cmd, +"devices/data_alignment_offset_detection" , +DEFAULT_DATA_ALIGNMENT_OFFSET_DETECTION )) { + data_alignment_offset = +dev_data_alignment_offset (pv->fmt->cmd->sysfs_dir, pv->dev); + } +if (pv->pe_start < pv->pe_align) pv->pe_start = pv->pe_align;
man/lvm.conf.5.in +7 -1
@@ -142,10 +142,16 @@ when creating a new Physical Volume using the \fBlvm2\fP format. If a Physical Volume is placed directly upon an md device and \fBmd_chunk_alignment\fP is enabled this parameter is ignored. Set to 0 to use the default alignment of 64KB or the page size, if larger. +.IP +\fBdata_alignment_offset_detection\fP \(em If set to 1, the offset to +the start of a PV's aligned data area will be set to the +alignment_offset exposed in sysfs. .sp To see the location of the first Physical Extent of an existing Physical Volume use \fBpvs -o +pe_start\fP . It will be a multiple of the requested -\fBdata_alignment\fP. +\fBdata_alignment\fP plus the alignment_offset from +\fBdata_alignment_offset_detection\fP (if enabled) or the pvcreate +commandline. .TP \fBlog\fP \(em Default log settings .IP
Signature · 1 line
1.6.2.2