master - vgcreate: Permit non-power-of-2 extent sizes.
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=5e6e2d6b1b984b83929dd23e75c0512e564d184f Commit: 5e6e2d6b1b984b83929dd23e75c0512e564d184f Parent: 02628413ca99648e70e38406384be69e20a2a6ce Author: Alasdair G Kergon <[email protected]> AuthorDate: Tue Oct 14 18:12:15 2014 +0100 Committer: Alasdair G Kergon <[email protected]> CommitterDate: Tue Oct 14 18:12:15 2014 +0100
vgcreate: Permit non-power-of-2 extent sizes.
Relax validation to permit extent sizes > 128KB that are not powers of 2 with lvm2 format. Existing code was already capable of handling this.
--- WHATS_NEW | 1 + lib/format1/disk-rep.h | 2 - lib/format1/format1.c | 21 +------ lib/format_text/format-text.c | 14 +++-- lib/metadata/metadata-exported.h | 2 + lib/metadata/metadata.h | 2 + lib/metadata/vg.c | 124 ++++++++++++++++++++++++-------------- lib/metadata/vg.h | 1 + man/vgchange.8.in | 9 ++- man/vgcreate.8.in | 9 ++- tools/vgconvert.c | 3 + 11 files changed, 107 insertions(+), 81 deletions(-)
WHATS_NEW +1 -0
@@ -1,5 +1,6 @@ Version 2.02.112 - ===================================== + Permit extent sizes > 128KB that are not power of 2 with lvm2 format. Remove workaround for lvm2-monitor.service hang on stop if lvmetad stopped. Change vgremove to use process_each_lv_in_vg. Introduce WARN_ flags to control some metadata warning messages.
lib/format1/disk-rep.h +0 -2
@@ -26,8 +26,6 @@#define LVM_BLK_MAJOR 58#define MAX_PV_SIZE ((uint32_t) -1)/* 2TB in sectors - 1 */ -#define MIN_PE_SIZE (8192L >> SECTOR_SHIFT)/* 8 KB in sectors */ -#define MAX_PE_SIZE (16L * 1024L * (1024L >> SECTOR_SHIFT) * 1024L)#define PE_SIZE_PV_SIZE_REL 5/* PV size must be at least 5 times PE size */ #define MAX_LE_TOTAL 65534/* 2^16 - 2 */ #define MAX_PE_TOTAL ((uint32_t) -2)
lib/format1/format1.c +2 -19
@@ -493,25 +493,8 @@ static int _format1_vg_setup(struct format_instance *fid, struct volume_group *vif (!vg->max_pv || vg->max_pv >=MAX_PV ) vg->max_pv =MAX_PV -1 ; -if (vg->extent_size >MAX_PE_SIZE || vg->extent_size <MIN_PE_SIZE ) { -log_error ("Extent size must be between %s and %s" , -display_size (fid->fmt->cmd, (uint64_t )MIN_PE_SIZE ), -display_size (fid->fmt->cmd, (uint64_t )MAX_PE_SIZE )); - -return 0 ; - } - -if (vg->extent_size %MIN_PE_SIZE ) { -log_error ("Extent size must be multiple of %s" , -display_size (fid->fmt->cmd, (uint64_t )MIN_PE_SIZE )); -return 0 ; - } - -/* Redundant? */ -if (vg->extent_size & (vg->extent_size -1 )) { -log_error ("Extent size must be power of 2" ); -return 0 ; - } +if (!vg_check_new_extent_size (vg->fid->fmt, vg->extent_size)) + return_0;return 1 ; }
lib/format_text/format-text.c +8 -6
@@ -72,13 +72,14 @@ void rlocn_set_ignored(struct raw_locn *rlocn, unsigned mda_ignored)* NOTE: Currently there can be only one vg per text file. */ -static int _text_vg_setup (struct format_instance *fid __attribute__((unused)), +/* +* Only used by vgcreate. +*/ +static int _text_vg_setup (struct format_instance *fid,struct volume_group *vg) { -if (vg->extent_size & (vg->extent_size -1 )) { -log_error ("Extent size must be power of 2" ); -return 0 ; - } +if (!vg_check_new_extent_size (vg->fid->fmt, vg->extent_size)) + return_0;return 1 ; }
@@ -2440,7 +2441,8 @@ struct format_type *create_text_format(struct cmd_context *cmd) fmt->orphan_vg_name =ORPHAN_VG_NAME (FMT_TEXT_NAME ); fmt->features =FMT_SEGMENTS |FMT_MDAS |FMT_TAGS |FMT_PRECOMMIT |FMT_UNLIMITED_VOLS |FMT_RESIZE_PV | -FMT_UNLIMITED_STRIPESIZE |FMT_BAS |FMT_CONFIG_PROFILE ; +FMT_UNLIMITED_STRIPESIZE |FMT_BAS |FMT_CONFIG_PROFILE | +FMT_NON_POWER2_EXTENTS ;if (!(mda_lists =dm_malloc (sizeof (struct mda_lists )))) {log_error ("Failed to allocate dir_list" );
lib/metadata/metadata-exported.h +2 -0
@@ -35,6 +35,7 @@#define STRIPE_SIZE_LIMIT ((UINT_MAX >> 2) + 1)#define MAX_RESTRICTED_LVS 255/* Used by FMT_RESTRICTED_LVIDS */ #define MAX_EXTENT_SIZE ((uint32_t) -1) +#define MIN_NON_POWER2_EXTENT_SIZE (128U * 2U)/* 128KB in sectors */ /* Layer suffix */ #define MIRROR_SYNC_LAYER "_mimagetmp"
@@ -132,6 +133,7 @@#define FMT_BAS 0x000000400U/* Supports bootloader areas? */ #define FMT_CONFIG_PROFILE 0x000000800U/* Supports configuration profiles? */ #define FMT_OBSOLETE 0x000001000U/* Obsolete format? */ +#define FMT_NON_POWER2_EXTENTS 0x000002000U/* Non-power-of-2 extent sizes? */ /* Mirror conversion type flags */ #define MIRROR_BY_SEG 0x00000001U/* segment-by-segment mirror */
lib/metadata/metadata.h +2 -0
@@ -33,6 +33,8 @@//#define STRIPE_SIZE_MAX ( 512L * 1024L >> SECTOR_SHIFT) /* 512 KB in sectors */ //#define STRIPE_SIZE_LIMIT ((UINT_MAX >> 2) + 1) //#define MAX_RESTRICTED_LVS 255 /* Used by FMT_RESTRICTED_LVIDS */ +#define MIN_PE_SIZE (8192L >> SECTOR_SHIFT)/* 8 KB in sectors - format1 only */ +#define MAX_PE_SIZE (16L * 1024L * (1024L >> SECTOR_SHIFT) * 1024L)/* format1 only */ #define MIRROR_LOG_OFFSET 2/* sectors */ #define VG_MEMPOOL_CHUNK 10240/* in bytes, hint only */
lib/metadata/vg.c +78 -46
219 lines not on this page · raw message
lib/metadata/vg.h +1 -0
@@ -147,6 +147,7 @@ int vg_set_clustered(struct volume_group *vg, int clustered);uint64_t vg_size (const struct volume_group *vg);uint64_t vg_free (const struct volume_group *vg);uint64_t vg_extent_size (const struct volume_group *vg); +int vg_check_new_extent_size (const struct format_type *fmt,uint32_t new_extent_size);int vg_set_extent_size (struct volume_group *vg,uint32_t new_extent_size);uint64_t vg_extent_count (const struct volume_group *vg);uint64_t vg_free_count (const struct volume_group *vg);
man/vgchange.8.in +5 -4
@@ -220,10 +220,11 @@ minimize metadata read and write overhead. .BR \-s ", " \-\-physicalextentsize " " \fIPhysicalExtentSize [ \fIBbBsSkKmMgGtTpPeE ] Changes the physical extent size on physical volumes of this volume group. A size suffix (k for kilobytes up to t for terabytes) is optional, megabytes -is the default if no suffix is present. The value must be at least 1 sector -for LVM2 format (where the sector size is the largest sector size of the -PVs currently used in the VG) or 8KiB for LVM1 format and it must be a -power of 2. The default is 4 MiB. +is the default if no suffix is present. For LVM2 format, the value must be a +power of 2 of at least 1 sector (where the sector size is the largest sector +size of the PVs currently used in the VG) or, if not a power of 2, at least +128KiB. For the older LVM1 format, it must be a power of 2 of at least 8KiB. +The default is 4 MiB. Before increasing the physical extent size, you might need to use lvresize, pvresize and/or pvmove so that everything fits. For example, every
man/vgcreate.8.in +5 -4
@@ -105,10 +105,11 @@ See \fBlvm.conf\fP(5) for more information about \fBmetadata profiles\fP. .BR \-s ", " \-\-physicalextentsize " " \fIPhysicalExtentSize [ \fIbBsSkKmMgGtTpPeE ] Sets the physical extent size on physical volumes of this volume group. A size suffix (k for kilobytes up to t for terabytes) is optional, megabytes -is the default if no suffix is present. The value must be at least 1 sector -for LVM2 format (where the sector size is the largest sector size of the -PVs currently used in the VG) or 8KiB for LVM1 format and it must be a -power of 2. The default is 4 MiB. +is the default if no suffix is present. For LVM2 format, the value must be a +power of 2 of at least 1 sector (where the sector size is the largest sector +size of the PVs currently used in the VG) or, if not a power of 2, at least +128KiB. For the older LVM1 format, it must be a power of 2 of at least 8KiB. +The default is 4 MiB. Once this value has been set, it is difficult to change it without recreating the volume group which would involve backing up and restoring data on any
tools/vgconvert.c +3 -0
@@ -66,6 +66,9 @@ static int vgconvert_single(struct cmd_context *cmd, const char *vg_name, rp.ba_size =arg_uint64_value (cmd, bootloaderareasize_ARG,UINT64_C (0 )); } +if (!vg_check_new_extent_size (cmd->fmt, vg->extent_size)) + return_ECMD_FAILED; +if (!archive (vg)) {log_error ("Archive of \"%s\" metadata failed." , vg_name);return ECMD_FAILED ;