: Add implicit pvcreate support in vgcreate / vgextend.
cover : Add implicit pvcreate support in vgcreate / vgextend.
This patch set is a rebase and rewrite of the earlier implicit pvcreate patchset. These patches should address most, if not all, feedback to date, and include updated tests. Once these patches are in, a user should no longer need pvcreate, except in rare recovery scenarios (usage of --uuid, --restorefile, and --physicalvolumesize are not supported with vgcreate and vgextend).
Patches 1-7 are just refactoring of existing code and should not change functionality. Patch 8 changes the behavior of vgcreate and vgextend to implicitly pvcreate if a device is not already initialized. Patch 9 updates the man pages and patch 10 the nightly tests.
One issue that has yet to be addressed is PV vs VG metadatacopies. A separate patch should address this soon after this patchset.
Applies cleanly and passes testsuite on the following commit:
commit 60ba4943ecb0cf6375de1d6711b4de9ea668d68b
Author: Zden?k Kabel?? <[email protected]> Date: Fri Oct 2 11:41:54 2009 +0000
Update distclean target for rename clogd to cmirrord. (2.02.52)
PATCH 1/10 Refactor vg_extend - add vg_extend_single_pv.
Simple refactor to setup future changes related to implicit pvcreates. Should be no functional change.
--- lib/metadata/metadata.c | 30 +++++++++++++++++++++++------- 1 files changed, 23 insertions(+), 7 deletions(-)
lib/metadata/metadata.c +23 -7
@@ -553,22 +553,38 @@ int vg_remove(struct volume_group *vg)return ret; } +/* +* Extend a VG by a single PV / device path +* +* Parameters: +* - vg: handle of volume group to extend by 'pv_name' +* - pv_name: device path of PV to add to VG +* +*/ +static int vg_extend_single_pv (struct volume_group *vg,char *pv_name) +{ +struct physical_volume *pv; + +if (!(pv =pv_by_path (vg->fid->fmt->cmd, pv_name))) { +log_error ("%s not identified as an existing " +"physical volume" , pv_name); +return 0 ; + } +if (!add_pv_to_vg (vg, pv_name, pv)) +return 0 ; +return 1 ; +} +int vg_extend (struct volume_group *vg,int pv_count,char **pv_names) {int i; -struct physical_volume *pv;if (_vg_bad_status_bits (vg,RESIZEABLE_VG ))return 0 ;/* attach each pv */ for (i =0 ; i < pv_count; i++) { -if (!(pv =pv_by_path (vg->fid->fmt->cmd, pv_names[i]))) { -log_error ("%s not identified as an existing " -"physical volume" , pv_names[i]); - goto bad; - } -if (!add_pv_to_vg (vg, pv_names[i], pv)) +if (!vg_extend_single_pv (vg, pv_names[i])) goto bad; }
Signature · 1 line
1.6.0.6
PATCH 2/10 Add pvcreate_params to vg_extend_single_pv.
Should be no functional change. If this parameter is set to NULL, just fail the extend if the device is not already a PV. If non-NULL, try pvcreate_single before failing. Note that pvcreate_single() handles the log_error in case of failure so we just return 0 if pvcreate_single() fails.
--- lib/metadata/metadata.c | 13 ++++++++++--- 1 files changed, 10 insertions(+), 3 deletions(-)
lib/metadata/metadata.c +10 -3
@@ -559,16 +559,23 @@ int vg_remove(struct volume_group *vg)* Parameters: * - vg: handle of volume group to extend by 'pv_name' * - pv_name: device path of PV to add to VG +* - pp: parameters to pass to implicit pvcreate; if NULL, do not pvcreate * */ -static int vg_extend_single_pv (struct volume_group *vg,char *pv_name) +static int vg_extend_single_pv (struct volume_group *vg,char *pv_name, +struct pvcreate_params *pp) {struct physical_volume *pv; -if (!(pv =pv_by_path (vg->fid->fmt->cmd, pv_name))) { + pv =pv_by_path (vg->fid->fmt->cmd, pv_name); +if (!pv && !pp) {log_error ("%s not identified as an existing " "physical volume" , pv_name);return 0 ; + }else if (!pv && pp) { + pv =pvcreate_single (vg->cmd, pv_name, pp); +if (!pv) +return 0 ; }if (!add_pv_to_vg (vg, pv_name, pv))return 0 ;
@@ -584,7 +591,7 @@ int vg_extend(struct volume_group *vg, int pv_count, char **pv_names)/* attach each pv */ for (i =0 ; i < pv_count; i++) { -if (!vg_extend_single_pv (vg, pv_names[i])) +if (!vg_extend_single_pv (vg, pv_names[i],NULL )) goto bad; }
Signature · 1 line
1.6.0.6
PATCH 3/10 Add pvcreate_params to vg_extend.
Another refactoring for implicit pvcreate support. We need to get the pvcreate parameters somehow to the vg_extend routine. Options seemed to be:
1. Attach the parameters to struct volume_group. I personally did not like this idea in most cases, though one could make an agrument why it might be ok at least for some of the parameters (e.g. metadatacopies).
2. Pass them in to the extend routine. This second route seemed to be the best approach given the constraints.
Future patches will parse the command line and fill in the actual values for the pvcreate_single call.
Should be no functional change.
--- lib/metadata/metadata-exported.h | 3 ++- lib/metadata/metadata.c | 15 +++++++++++++-- liblvm/lvm_vg.c | 2 +- tools/vgcreate.c | 2 +- tools/vgextend.c | 2 +- 5 files changed, 18 insertions(+), 6 deletions(-)
lib/metadata/metadata-exported.h +2 -1
@@ -453,7 +453,8 @@ int vg_remove_check(struct volume_group *vg);int vg_remove (struct volume_group *vg);int vg_rename (struct cmd_context *cmd,struct volume_group *vg,const char *new_name); -int vg_extend (struct volume_group *vg,int pv_count,char **pv_names); +int vg_extend (struct volume_group *vg,int pv_count,char **pv_names, +struct pvcreate_params *pp);int vg_reduce (struct volume_group *vg,char *pv_name);int vg_set_extent_size (struct volume_group *vg,uint32_t new_extent_size);int vg_set_max_lv (struct volume_group *vg,uint32_t max_lv);
lib/metadata/metadata.c +13 -2
@@ -582,7 +582,18 @@ static int vg_extend_single_pv(struct volume_group *vg, char *pv_name,return 1 ; } -int vg_extend (struct volume_group *vg,int pv_count,char **pv_names) +/* +* Extend a VG by a single PV / device path +* +* Parameters: +* - vg: handle of volume group to extend by 'pv_name' +* - pv_count: count of device paths of PVs +* - pv_names: device paths of PVs to add to VG +* - pp: parameters to pass to implicit pvcreate; if NULL, do not pvcreate +* +*/ +int vg_extend (struct volume_group *vg,int pv_count,char **pv_names, +struct pvcreate_params *pp) {int i;
@@ -591,7 +602,7 @@ int vg_extend(struct volume_group *vg, int pv_count, char **pv_names)/* attach each pv */ for (i =0 ; i < pv_count; i++) { -if (!vg_extend_single_pv (vg, pv_names[i],NULL )) +if (!vg_extend_single_pv (vg, pv_names[i], pp)) goto bad; }
liblvm/lvm_vg.c +1 -1
@@ -60,7 +60,7 @@ int lvm_vg_extend(vg_t vg, const char *device)return -1 ; } -if (!vg_extend (vg,1 , (char **) &device)) { +if (!vg_extend (vg,1 , (char **) &device,NULL )) {unlock_vg (vg->cmd,VG_ORPHANS );return -1 ; }
tools/vgcreate.c +1 -1
@@ -63,7 +63,7 @@ int vgcreate(struct cmd_context *cmd, int argc, char **argv) }/* attach the pv's */ -if (!vg_extend (vg, argc -1 , argv +1 )) +if (!vg_extend (vg, argc -1 , argv +1 ,NULL )) goto_bad;if (vp_new.max_lv != vg->max_lv)
tools/vgextend.c +1 -1
@@ -54,7 +54,7 @@ int vgextend(struct cmd_context *cmd, int argc, char **argv) goto_bad;/* extend vg */ -if (!vg_extend (vg, argc, argv)) +if (!vg_extend (vg, argc, argv,NULL )) goto_bad;/* ret > 0 */
Signature · 1 line
1.6.0.6
PATCH 4/10 Allow calling fill_default_pvcreate_params from tools.
We need defaults for pvcreate_params at a higher level - this will allow us to use a common function from the tools to take defaults, then fill in any non-defaults from the commandline.
Future patches will refactor vgcreate/vgextend to call this function if one or more pvcreate parameters are given on the commandline.
--- lib/metadata/metadata-exported.h | 1 + lib/metadata/metadata.c | 2 +- liblvm/lvm_vg.c | 13 ++++--------- 3 files changed, 6 insertions(+), 10 deletions(-)
lib/metadata/metadata-exported.h +1 -0
@@ -371,6 +371,7 @@ struct pvcreate_params {struct physical_volume *pvcreate_single (struct cmd_context *cmd,const char *pv_name,struct pvcreate_params *pp); +void fill_default_pvcreate_params (struct pvcreate_params *pp);/* * Utility functions
lib/metadata/metadata.c +1 -1
@@ -1272,7 +1272,7 @@ static int pvcreate_check(struct cmd_context *cmd, const char *name,return 1 ; } -static void fill_default_pvcreate_params (struct pvcreate_params *pp) +void fill_default_pvcreate_params (struct pvcreate_params *pp) {memset (pp,0 ,sizeof (*pp)); pp->zero =0 ;
liblvm/lvm_vg.c +4 -9
@@ -41,6 +41,8 @@ vg_t lvm_vg_create(lvm_t libh, const char *vg_name)int lvm_vg_extend (vg_t vg,const char *device) { +struct pvcreate_params pp; +if (vg_read_error (vg))return -1 ;
@@ -52,15 +54,8 @@ int lvm_vg_extend(vg_t vg, const char *device)return -1 ; } -/* If device not initialized, pvcreate it */ -if (!pv_by_path (vg->cmd, device) && - (!pvcreate_single (vg->cmd, device,NULL ))) { -log_error ("Unable to initialize device for LVM use" ); -unlock_vg (vg->cmd,VG_ORPHANS ); -return -1 ; - } - -if (!vg_extend (vg,1 , (char **) &device,NULL )) { +fill_default_pvcreate_params (&pp); +if (!vg_extend (vg,1 , (char **) &device, &pp)) {unlock_vg (vg->cmd,VG_ORPHANS );return -1 ; }
Signature · 1 line
1.6.0.6
PATCH 5/10 Refactor pvcreate - split pvcreate_validate_params into recovery/non-recovery.
Split pvcreate_validate_params into recovery and non-recovery parameters. This is necessary so we can call the non-recovery validate function from vgextend / vgcreate. Note in the pvcreate tool case, we must call the recovery validation function first (see treatment of pe_start and --zero), and that we add a call to fill_default_pvcreate_params before the validation functions.
--- lib/metadata/metadata.c | 2 +- tools/pvcreate.c | 62 ++++++++++++++++++++++++++++------------------- 2 files changed, 38 insertions(+), 26 deletions(-)
lib/metadata/metadata.c +1 -1
@@ -1275,7 +1275,7 @@ static int pvcreate_check(struct cmd_context *cmd, const char *name,void fill_default_pvcreate_params (struct pvcreate_params *pp) {memset (pp,0 ,sizeof (*pp)); - pp->zero =0 ; + pp->zero =1 ; pp->size =0 ; pp->data_alignment =UINT64_C (0 ); pp->data_alignment_offset =UINT64_C (0 );
tools/pvcreate.c +37 -25
100 lines not on this page · raw message
Signature · 1 line
1.6.0.6
PATCH 6/10 Refactor vgcreate/vgextend validation of vgname/pvname(s).
Decrement argc and increment argv in a consistent way to allow for later code-sharing. Should be no functional change.
--- tools/vgcreate.c | 11 ++++++++--- tools/vgextend.c | 10 +++++----- 2 files changed, 13 insertions(+), 8 deletions(-)
tools/vgcreate.c +8 -3
@@ -22,6 +22,7 @@ int vgcreate(struct cmd_context *cmd, int argc, char **argv)struct volume_group *vg;const char *tag;const char *clustered_message ="" ; +char *vg_name;if (!argc) { log_error("Please provide volume group name and "
@@ -29,7 +30,11 @@ int vgcreate(struct cmd_context *cmd, int argc, char **argv)return EINVALID_CMD_LINE ; } -if (argc ==1 ) { + vg_name = argv[0 ]; + argc--; + argv++; + +if (argc ==0 ) {log_error ("Please enter physical volume name(s)" );return EINVALID_CMD_LINE ; }
@@ -40,7 +45,7 @@ int vgcreate(struct cmd_context *cmd, int argc, char **argv) vp_def.max_lv =DEFAULT_MAX_LV ; vp_def.alloc =DEFAULT_ALLOC_POLICY ; vp_def.clustered =DEFAULT_CLUSTERED ; -if (fill_vg_create_params (cmd, argv[0 ], &vp_new, &vp_def)) +if (fill_vg_create_params (cmd, vg_name, &vp_new, &vp_def))return EINVALID_CMD_LINE ;if (validate_vg_create_params (cmd, &vp_new))
@@ -63,7 +68,7 @@ int vgcreate(struct cmd_context *cmd, int argc, char **argv) }/* attach the pv's */ -if (!vg_extend (vg, argc -1 , argv +1 ,NULL )) +if (!vg_extend (vg, argc, argv,NULL )) goto_bad;if (vp_new.max_lv != vg->max_lv)
tools/vgextend.c +5 -5
@@ -27,15 +27,15 @@ int vgextend(struct cmd_context *cmd, int argc, char **argv)return EINVALID_CMD_LINE ; } -if (argc ==1 ) { -log_error ("Please enter physical volume(s)" ); -return EINVALID_CMD_LINE ; - } - vg_name =skip_dev_dir (cmd, argv[0 ],NULL ); argc--; argv++; +if (argc ==0 ) { +log_error ("Please enter physical volume(s)" ); +return EINVALID_CMD_LINE ; + } +log_verbose ("Checking for volume group \"%s\"" , vg_name); vg =vg_read_for_update (cmd, vg_name,NULL ,0 );if (vg_read_error (vg)) {
Signature · 1 line
1.6.0.6
PATCH 7/10 Move pvcreate_validate_params into toollib to allow calling from mutiple tools.
For implicit pvcreate support, we need to call this from vgcreate and vgextend, so move it into toollib.
--- tools/pvcreate.c | 108 ----------------------------------------------------- tools/toollib.c | 109 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ tools/toollib.h | 3 + 3 files changed, 112 insertions(+), 108 deletions(-)
tools/pvcreate.c +0 -108
@@ -78,114 +78,6 @@ static int pvcreate_validate_restore_params(struct cmd_context *cmd,return 1 ; } -/* -* Intial sanity checking of non-recovery related command-line arguments. -* -* Output arguments: -* pp: structure allocated by caller, fields written / validated here -*/ -static int pvcreate_validate_params (struct cmd_context *cmd, -int argc,char **argv, -struct pvcreate_params *pp) -{ -if (!argc) { -log_error ("Please enter a physical volume path" ); -return 0 ; - } - -if (arg_count (cmd, yes_ARG) && !arg_count (cmd, force_ARG)) { -log_error ("Option y can only be given with option f" ); -return 0 ; - } - - pp->yes =arg_count (cmd, yes_ARG); - pp->force =arg_count (cmd, force_ARG); - -if (arg_int_value (cmd, labelsector_ARG,0 ) >=LABEL_SCAN_SECTORS ) { -log_error ("labelsector must be less than %lu" , -LABEL_SCAN_SECTORS ); -return 0 ; - }else { - pp->labelsector =arg_int64_value (cmd, labelsector_ARG, -DEFAULT_LABELSECTOR ); - } - -if (!(cmd->fmt->features &FMT_MDAS ) && - (arg_count (cmd, metadatacopies_ARG) || -arg_count (cmd, metadatasize_ARG) || -arg_count (cmd, dataalignment_ARG) || -arg_count (cmd, dataalignmentoffset_ARG))) { -log_error ("Metadata and data alignment parameters only " -"apply to text format." ); -return 0 ; - } - -if (arg_count (cmd, metadatacopies_ARG) && -arg_int_value (cmd, metadatacopies_ARG,-1 ) >2 ) { -log_error ("Metadatacopies may only be 0, 1 or 2" ); -return 0 ; - } - -if (arg_count (cmd, zero_ARG)) - pp->zero =strcmp (arg_str_value (cmd, zero_ARG,"y" ),"n" ); - -if (arg_sign_value (cmd, dataalignment_ARG,0 ) ==SIGN_MINUS ) { -log_error ("Physical volume data alignment may not be negative" ); -return 0 ; - } - pp->data_alignment =arg_uint64_value (cmd, dataalignment_ARG,UINT64_C (0 )); - -if (pp->data_alignment >ULONG_MAX ) { -log_error ("Physical volume data alignment is too big." ); -return 0 ; - } - -if (pp->data_alignment && pp->pe_start) { -if (pp->pe_start % pp->data_alignment) -log_warn ("WARNING: Ignoring data alignment %" PRIu64 -" incompatible with --restorefile value (%" - PRIu64")." , pp->data_alignment, pp->pe_start); - 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 ; - } - - pp->pvmetadatasize =arg_uint64_value (cmd, metadatasize_ARG,UINT64_C (0 )); -if (!pp->pvmetadatasize) - pp->pvmetadatasize =find_config_tree_int (cmd, -"metadata/pvmetadatasize" , -DEFAULT_PVMETADATASIZE ); - - pp->pvmetadatacopies =arg_int_value (cmd, metadatacopies_ARG,-1 ); -if (pp->pvmetadatacopies <0 ) - pp->pvmetadatacopies =find_config_tree_int (cmd, -"metadata/pvmetadatacopies" , -DEFAULT_PVMETADATACOPIES ); - -return 1 ; -} -int pvcreate (struct cmd_context *cmd,int argc,char **argv) {int i;
tools/toollib.c +109 -0
112 lines not on this page · raw message
tools/toollib.h +3 -0
@@ -107,5 +107,8 @@ int lv_refresh(struct cmd_context *cmd, struct logical_volume *lv);int vg_refresh_visible (struct cmd_context *cmd,struct volume_group *vg);void lv_spawn_background_polling (struct cmd_context *cmd,struct logical_volume *lv); +int pvcreate_validate_params (struct cmd_context *cmd, +int argc,char **argv, +struct pvcreate_params *pp);#endif
Signature · 1 line
1.6.0.6
PATCH 8/10 Add implicit pvcreate support to vgcreate and vgextend.
Adds implicit pvcreate support when calling vgcreate or vgextend with device paths that are not yet PVs. This changes the behavior of vgcreate and vgextend from failing with an error message to implicitly pvcreating.
--- tools/commands.h | 9 +++++++-- tools/vgcreate.c | 7 ++++--- tools/vgextend.c | 7 ++++--- 3 files changed, 15 insertions(+), 8 deletions(-)
tools/commands.h +7 -2
@@ -757,7 +757,9 @@ xx(vgcreate, "\tVolumeGroupName PhysicalVolume [PhysicalVolume...]\n", addtag_ARG, alloc_ARG, autobackup_ARG, clustered_ARG, maxlogicalvolumes_ARG, - maxphysicalvolumes_ARG, metadatatype_ARG, physicalextentsize_ARG, test_ARG) + maxphysicalvolumes_ARG, metadatatype_ARG, physicalextentsize_ARG, test_ARG, + force_ARG, yes_ARG, zero_ARG, labelsector_ARG, metadatasize_ARG, + metadatacopies_ARG, dataalignment_ARG, dataalignmentoffset_ARG) xx(vgdisplay, "Display volume group information",
@@ -820,7 +822,10 @@ xx(vgextend, "\t[--version]" "\n" "\tVolumeGroupName PhysicalDevicePath [PhysicalDevicePath...]\n", - autobackup_ARG, test_ARG) + autobackup_ARG, test_ARG, + force_ARG, yes_ARG, zero_ARG, labelsector_ARG, metadatatype_ARG, + metadatasize_ARG, metadatacopies_ARG, dataalignment_ARG, + dataalignmentoffset_ARG) xx(vgimport, "Register exported volume group with system",
tools/vgcreate.c +4 -3
@@ -23,6 +23,7 @@ int vgcreate(struct cmd_context *cmd, int argc, char **argv)const char *tag;const char *clustered_message ="" ;char *vg_name; +struct pvcreate_params pp;if (!argc) { log_error("Please provide volume group name and "
@@ -34,8 +35,8 @@ int vgcreate(struct cmd_context *cmd, int argc, char **argv) argc--; argv++; -if (argc ==0 ) { -log_error ("Please enter physical volume name(s)" ); +fill_default_pvcreate_params (&pp); +if (!pvcreate_validate_params (cmd, argc, argv, &pp)) {return EINVALID_CMD_LINE ; }
@@ -68,7 +69,7 @@ int vgcreate(struct cmd_context *cmd, int argc, char **argv) }/* attach the pv's */ -if (!vg_extend (vg, argc, argv,NULL )) +if (!vg_extend (vg, argc, argv, &pp)) goto_bad;if (vp_new.max_lv != vg->max_lv)
tools/vgextend.c +4 -3
@@ -20,6 +20,7 @@ int vgextend(struct cmd_context *cmd, int argc, char **argv)char *vg_name;struct volume_group *vg =NULL ;int r =ECMD_FAILED ; +struct pvcreate_params pp;if (!argc) { log_error("Please enter volume group name and "
@@ -31,8 +32,8 @@ int vgextend(struct cmd_context *cmd, int argc, char **argv) argc--; argv++; -if (argc ==0 ) { -log_error ("Please enter physical volume(s)" ); +fill_default_pvcreate_params (&pp); +if (!pvcreate_validate_params (cmd, argc, argv, &pp)) {return EINVALID_CMD_LINE ; }
@@ -54,7 +55,7 @@ int vgextend(struct cmd_context *cmd, int argc, char **argv) goto_bad;/* extend vg */ -if (!vg_extend (vg, argc, argv,NULL )) +if (!vg_extend (vg, argc, argv, &pp)) goto_bad;/* ret > 0 */
Signature · 1 line
1.6.0.6
PATCH 9/10 Update vgcreate and vgextend man pages to clarify implicit pvcreate.
vgcreate and vgextend now implicitly call pvcreate on devices not currently initialized for LVM use. Previously these commands would fail with an error, so clarify the new behavior in the man page.
--- man/vgcreate.8.in | 39 +++++++++++++++++++++++++++++++++------ man/vgextend.8.in | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+), 6 deletions(-)
man/vgcreate.8.in +33 -6
@@ -21,16 +21,24 @@ vgcreate \- create a volume group .RB [ \-t | \-\-test ] .RB [ \-v | \-\-verbose ] .RB [ \-\-version ] -.I VolumeGroupName PhysicalVolumePath -.RI [ PhysicalVolumePath ...] +.RB [ PHYSICAL DEVICE OPTIONS ] +.I VolumeGroupName PhysicalDevicePath +.RI [ PhysicalDevicePath ...] .SH DESCRIPTION .B vgcreate creates a new volume group called .I VolumeGroupName -using the block special device -.IR PhysicalVolumePath -previously configured for LVM with -.BR pvcreate (8). +using the block special device \fIPhysicalDevicePath\fP. +.sp +If \fIPhysicalDevicePath\fP was not previously configured for LVM with +\fBpvcreate (8)\fP, the device will be initialized with the same +default values used with \fBpvcreate\fP. If non-default +\fPpvcreate\fP values are are desired, they may be given on the +commandline with the same options as \fPpvcreate\fP. See +\fBPHYSICAL DEVICE OPTIONS\fP for available options. Note +that the restore-related options such as --restorefile, --uuid, +and --physicalvolumesize are not available. If a restore operation +is needed, use \fBpvcreate (8)\fP and \fBvgcfgrestore (8)\fP. .SH OPTIONS See \fBlvm\fP for common options. .TP
@@ -86,6 +94,25 @@ but having a large number of extents will slow down the tools but have no impact on I/O performance to the logical volume. The smallest PE is 1KB. The 2.4 kernel has a limitation of 2TB per block device. +.SH PHYSICAL DEVICE OPTIONS +The following options are available for initializing physical devices in the +volume group. These options are further described in the pvcreate man page. +.TP +.BR \-f ", " \-\-force +.TP +.BR \-y ", " \-\-yes +.TP +.BR \-Z ", " \-\-zero " y|n" +.TP +.BR \-\-labelsector " sector" +.TP +.BR \-\-metadatasize " size" +.TP +.BR \-\-metadatacopies " copies" +.TP +.BR \-\-dataalignment " alignment" +.TP +.BR \-\-dataalignmentoffset " alignment_offset" .SH EXAMPLES To create a volume group named .B test_vg
man/vgextend.8.in +34 -0
@@ -6,13 +6,47 @@ vgextend \- add physical volumes to a volume group [\-A|\-\-autobackup y|n] [\-d|\-\-debug] [\-h|\-?|\-\-help] [\-t|\-\-test] [\-v|\-\-verbose] +.RB [ PHYSICAL DEVICE OPTIONS ] VolumeGroupName PhysicalDevicePath [PhysicalDevicePath...] .SH DESCRIPTION vgextend allows you to add one or more initialized physical volumes ( see .B pvcreate(8) ) to an existing volume group to extend it in size. +.sp +If \fIPhysicalDevicePath\fP was not previously configured for LVM with +\fBpvcreate (8)\fP, the device will be initialized with the same +default values used with \fBpvcreate\fP. If non-default +\fPpvcreate\fP values are are desired, they may be given on the +commandline with the same options as \fPpvcreate\fP. See +\fBPHYSICAL DEVICE OPTIONS\fP for available options. Note +that the restore-related options such as --restorefile, --uuid, +and --physicalvolumesize are not available. If a restore operation +is needed, use \fBpvcreate (8)\fP and \fBvgcfgrestore (8)\fP. +\fBpvcreate (8)\fP, the device will be initialized with the same +default values used with \fBpvcreate\fP. If non-default +\fPpvcreate\fP values are are desired, \fBpvcreate\fP should be explicitly +called prior to calling \fBvgcreate\fP. .SH OPTIONS See \fBlvm\fP for common options. +.SH PHYSICAL DEVICE OPTIONS +The following options are available for initializing physical devices in the +volume group. These options are further described in the pvcreate man page. +.TP +.BR \-f ", " \-\-force +.TP +.BR \-y ", " \-\-yes +.TP +.BR \-Z ", " \-\-zero " y|n" +.TP +.BR \-\-labelsector " sector" +.TP +.BR \-\-metadatasize " size" +.TP +.BR \-\-metadatacopies " copies" +.TP +.BR \-\-dataalignment " alignment" +.TP +.BR \-\-dataalignmentoffset " alignment_offset" .SH Examples "vgextend vg00 /dev/sda4 /dev/sdn1" tries to extend the existing volume group "vg00" by the new physical volumes (see
Signature · 1 line
1.6.0.6
PATCH 10/10 Add implicit tests for implicit pvcreate during vgcreate and vgextend.
Update tests and WHATS_NEW for implicit pvcreate support.
--- WHATS_NEW | 1 + test/t-vgcreate-usage.sh | 57 ++++++++++++++++++++++++++++++++++ test/t-vgextend-usage.sh | 77 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 135 insertions(+), 0 deletions(-) create mode 100644 test/t-vgextend-usage.sh
WHATS_NEW +1 -0
@@ -1,5 +1,6 @@ Version 2.02.54 - ===================================== + Add implict pvcreate support to vgcreate and vgextend. Update distclean target for rename clogd to cmirrord. (2.02.52) Only do lock conversions in clvmd if we are explicitly asked for one. Introduce percent_range_t and centralise snapshot full/mirror in-sync checks.
test/t-vgcreate-usage.sh +57 -0
60 lines not on this page · raw message
test/t-vgextend-usage.sh new file +77 -0
77 lines not on this page · raw message
Signature · 1 line
1.6.0.6
PATCH 1/1 Add --pvmetadatacopies as a synonym for --metadatacopies in various commands.
Going forward, we would like to allow users to specify the total number of metadatacopies in a VG rather than on a per-PV basis. In order to facilitate that, introduce --pvmetadatacopes to replace --metadatacopies everywhere. We still allow --metadatacopies everywhere, but eventually we will introduce --vgmetadatacopies. Once we do that, we should either deprecate --metadatacopies or make it a synonym based on the command (pvmetadatacopies for pv commands, and vgmetadatacopies for vg commands). The latter option would likely just require a simple 'strncpy' check against cmd->command->name to qualify the merge_synonym call.
Update nightly tests to cover the pvmetadatacopies synonym.
Note that this patch is the result of an eariler review comment for the implicit pvcreate patches. Should apply cleanly on top of the implicit pvcreate patches (I applied after patch 10/10 in that series).
--- man/pvcreate.8.in | 4 ++-- man/vgchange.8.in | 2 +- man/vgconvert.8.in | 2 +- man/vgcreate.8.in | 4 ++-- man/vgextend.8.in | 2 +- test/t-pvcreate-usage.sh | 15 +++++++++------ test/t-vgcreate-usage.sh | 7 +++++-- test/t-vgextend-usage.sh | 5 ++++- tools/args.h | 1 + tools/commands.h | 18 ++++++++++-------- tools/lvmcmdline.c | 3 ++- tools/toollib.c | 8 ++++---- 12 files changed, 42 insertions(+), 29 deletions(-)
man/pvcreate.8.in +2 -2
@@ -11,7 +11,7 @@ pvcreate \- initialize a disk or partition for use by LVM .RB [ \-v | \-\-verbose ] .RB [ \-\-labelsector ] .RB [ \-M | \-\-metadatatype type ] -.RB [ \-\-metadatacopies #copies ] +.RB [ \-\-pvmetadatacopies #copies ] .RB [ \-\-metadatasize size ] .RB [ \-\-dataalignment alignment ] .RB [ \-\-dataalignmentoffset alignment_offset ]
@@ -105,7 +105,7 @@ use \fBpvs -o +pe_start\fP . It will be a multiple of the requested .BR \-\-dataalignmentoffset " alignment_offset" Shift the start of the data area by this additional \fBalignment_offset\fP. .TP -.BR \-\-metadatacopies " copies" +.BR \-\-pvmetadatacopies " copies" The number of metadata areas to set aside on each PV. Currently this can be 0, 1 or 2. If set to 2, two copies of the volume group metadata
man/vgchange.8.in +1 -1
@@ -113,7 +113,7 @@ removes this restriction: there is then no limit. If you have a large number of physical volumes in a volume group with metadata in lvm2 format, for tool performance reasons, you should consider -some use of \fB--metadatacopies 0\fP +some use of \fB--pvmetadatacopies 0\fP as described in \fBpvcreate(8)\fP. .TP .BR \-s ", " \-\-physicalextentsize " " \fIPhysicalExtentSize\fR[\fBbBsSkKmMgGtTpPeE\fR]
man/vgconvert.8.in +1 -1
@@ -9,7 +9,7 @@ vgconvert \- convert volume group metadata format .RB [ \-v | \-\-verbose ] .RB [ \-\-labelsector ] .RB [ \-M | \-\-metadatatype type ] -.RB [ \-\-metadatacopies #copies ] +.RB [ \-\-pvmetadatacopies #copies ] .RB [ \-\-metadatasize size ] .RB [ \-\-version ] .IR VolumeGroupName " [" VolumeGroupName ...]
man/vgcreate.8.in +2 -2
@@ -71,7 +71,7 @@ which removes this restriction: there is then no limit. If you have a large number of physical volumes in a volume group with metadata in lvm2 format, for tool performance reasons, you should consider -some use of \fB--metadatacopies 0\fP +some use of \fB--pvmetadatacopies 0\fP as described in \fBpvcreate(8)\fP. .TP .BR \-s ", " \-\-physicalextentsize " " \fIPhysicalExtentSize\fR[\fBbBsSkKmMgGtTpPeE\fR]
@@ -108,7 +108,7 @@ volume group. These options are further described in the pvcreate man page. .TP .BR \-\-metadatasize " size" .TP -.BR \-\-metadatacopies " copies" +.BR \-\-pvmetadatacopies " copies" .TP .BR \-\-dataalignment " alignment" .TP
man/vgextend.8.in +1 -1
@@ -42,7 +42,7 @@ volume group. These options are further described in the pvcreate man page. .TP .BR \-\-metadatasize " size" .TP -.BR \-\-metadatacopies " copies" +.BR \-\-pvmetadatacopies " copies" .TP .BR \-\-dataalignment " alignment" .TP
test/t-pvcreate-usage.sh +9 -6
@@ -46,15 +46,18 @@ vgremove -ff $vg not pvcreate --metadatacopies -1 $dev1 #COMM 'pvcreate accepts metadatacopies = 0, 1, 2' -pvcreate --metadatacopies 0 $dev1 -pvcreate --metadatacopies 1 $dev2 -pvcreate --metadatacopies 2 $dev3 -check_pv_field_ $dev1 pv_mda_count 0 -check_pv_field_ $dev2 pv_mda_count 1 -check_pv_field_ $dev3 pv_mda_count 2 +for j in metadatacopies pvmetadatacopies +do +pvcreate --$j 0 $dev1 +pvcreate --$j 1 $dev2 +pvcreate --$j 2 $dev3 +check_pv_field_ $dev1 pv_mda_count 0 +check_pv_field_ $dev2 pv_mda_count 1 +check_pv_field_ $dev3 pv_mda_count 2 pvremove $dev1 pvremove $dev2 pvremove $dev3 +done #COMM 'pvcreate rejects metadatacopies > 2' not pvcreate --metadatacopies 3 $dev1
test/t-vgcreate-usage.sh +5 -2
@@ -105,14 +105,17 @@ do pvremove -f $dev1 done -# metadatacopies +# metadatacopies, pvmetadatacopies for i in 1 2 do - vgcreate --metadatacopies $i $vg $dev1 +for j in metadatacopies pvmetadatacopies +do + vgcreate --$j $i $vg $dev1 check_pv_field_ $dev1 pv_mda_count $i vgremove -f $vg pvremove -f $dev1 done +done not vgcreate --metadatacopies 0 $vg $dev1 pvcreate --metadatacopies 1 $dev2 vgcreate --metadatacopies 0 $vg $dev1 $dev2
test/t-vgextend-usage.sh +4 -1
@@ -54,11 +54,14 @@ done # metadatacopies for i in 0 1 2 do - vgextend --metadatacopies $i $vg $dev1 +for j in metadatacopies pvmetadatacopies +do + vgextend --$j $i $vg $dev1 check_pv_field_ $dev1 pv_mda_count $i vgreduce $vg $dev1 pvremove -f $dev1 done +done # metadatasize, dataalignment, dataalignmentoffset #COMM 'pvcreate sets data offset next to mda area'
tools/args.h +1 -0
@@ -23,6 +23,7 @@ arg(quiet_ARG, '\0', "quiet", NULL, 0) arg(physicalvolumesize_ARG, '\0', "setphysicalvolumesize", size_mb_arg, 0) arg(ignorelockingfailure_ARG, '\0', "ignorelockingfailure", NULL, 0) arg(nolocking_ARG, '\0', "nolocking", NULL, 0) +arg(pvmetadatacopies_ARG, '\0', "pvmetadatacopies", int_arg, 0) arg(metadatacopies_ARG, '\0', "metadatacopies", int_arg, 0) arg(metadatasize_ARG, '\0', "metadatasize", size_mb_arg, 0)arg (restorefile_ARG,'\0' ,"restorefile" , string_arg,0 )
tools/commands.h +10 -8
@@ -479,7 +479,7 @@ xx(pvcreate,"\t[-h|-?|--help] " "\n" "\t[--labelsector sector] " "\n" "\t[-M|--metadatatype 1|2]" "\n" -"\t[--metadatacopies #copies]" "\n" +"\t[--pvmetadatacopies #copies]" "\n" "\t[--metadatasize MetadataSize[bBsSkKmMgGtTpPeE]]" "\n" "\t[--dataalignment Alignment[bBsSkKmMgGtTpPeE]]" "\n" "\t[--dataalignmentoffset AlignmentOffset[bBsSkKmMgGtTpPeE]]" "\n"
@@ -493,8 +493,9 @@ xx(pvcreate, "\tPhysicalVolume [PhysicalVolume...]\n", 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) + labelsector_ARG, metadatatype_ARG, metadatacopies_ARG, pvmetadatacopies_ARG, + metadatasize_ARG, physicalvolumesize_ARG, restorefile_ARG, uuidstr_ARG, + yes_ARG, zero_ARG) xx(pvdata, "Display the on-disk metadata for physical volume(s)",
@@ -727,7 +728,7 @@ xx(vgconvert,"\t[-h|--help] " "\n" "\t[--labelsector sector] " "\n" "\t[-M|--metadatatype 1|2]" "\n" -"\t[--metadatacopies #copies]" "\n" +"\t[--pvmetadatacopies #copies]" "\n" "\t[--metadatasize MetadataSize[bBsSkKmMgGtTpPeE]]" "\n" "\t[-t|--test] " "\n" "\t[-v|--verbose] " "\n"
@@ -735,7 +736,7 @@ xx(vgconvert, "\tVolumeGroupName [VolumeGroupName...]\n", force_ARG, test_ARG, labelsector_ARG, metadatatype_ARG, metadatacopies_ARG, - metadatasize_ARG ) + pvmetadatacopies_ARG, metadatasize_ARG ) xx(vgcreate, "Create a volume group",
@@ -760,7 +761,8 @@ xx(vgcreate, addtag_ARG, alloc_ARG, autobackup_ARG, clustered_ARG, maxlogicalvolumes_ARG, maxphysicalvolumes_ARG, metadatatype_ARG, physicalextentsize_ARG, test_ARG, force_ARG, yes_ARG, zero_ARG, labelsector_ARG, metadatasize_ARG, - metadatacopies_ARG, dataalignment_ARG, dataalignmentoffset_ARG) + pvmetadatacopies_ARG, metadatacopies_ARG, dataalignment_ARG, + dataalignmentoffset_ARG) xx(vgdisplay, "Display volume group information",
@@ -826,8 +828,8 @@ xx(vgextend, autobackup_ARG, test_ARG, force_ARG, yes_ARG, zero_ARG, labelsector_ARG, metadatatype_ARG, - metadatasize_ARG, metadatacopies_ARG, dataalignment_ARG, - dataalignmentoffset_ARG) + metadatasize_ARG, pvmetadatacopies_ARG, metadatacopies_ARG, + dataalignment_ARG, dataalignmentoffset_ARG) xx(vgimport, "Register exported volume group with system",
tools/lvmcmdline.c +2 -1
@@ -837,7 +837,8 @@ static int _get_settings(struct cmd_context *cmd)if (!_merge_synonym (cmd, resizable_ARG, resizeable_ARG) || !_merge_synonym (cmd, allocation_ARG, allocatable_ARG) || !_merge_synonym (cmd, allocation_ARG, resizeable_ARG) || - !_merge_synonym (cmd, virtualoriginsize_ARG, virtualsize_ARG)) + !_merge_synonym (cmd, virtualoriginsize_ARG, virtualsize_ARG) || + !_merge_synonym (cmd, metadatacopies_ARG, pvmetadatacopies_ARG))return EINVALID_CMD_LINE ;/* Zero indicates success */
tools/toollib.c +4 -4
@@ -1305,7 +1305,7 @@ int pvcreate_validate_params(struct cmd_context *cmd, }if (!(cmd->fmt->features &FMT_MDAS ) && - (arg_count (cmd, metadatacopies_ARG) || + (arg_count (cmd, pvmetadatacopies_ARG) ||arg_count (cmd, metadatasize_ARG) ||arg_count (cmd, dataalignment_ARG) ||arg_count (cmd, dataalignmentoffset_ARG))) {
@@ -1314,8 +1314,8 @@ int pvcreate_validate_params(struct cmd_context *cmd,return 0 ; } -if (arg_count (cmd, metadatacopies_ARG) && -arg_int_value (cmd, metadatacopies_ARG,-1 ) >2 ) { +if (arg_count (cmd, pvmetadatacopies_ARG) && +arg_int_value (cmd, pvmetadatacopies_ARG,-1 ) >2 ) {log_error ("Metadatacopies may only be 0, 1 or 2" );return 0 ; }
@@ -1371,7 +1371,7 @@ int pvcreate_validate_params(struct cmd_context *cmd,"metadata/pvmetadatasize" , DEFAULT_PVMETADATASIZE); - pp->pvmetadatacopies =arg_int_value (cmd, metadatacopies_ARG,-1 ); + pp->pvmetadatacopies =arg_int_value (cmd, pvmetadatacopies_ARG,-1 );if (pp->pvmetadatacopies <0 ) pp->pvmetadatacopies = find_config_tree_int(cmd, "metadata/pvmetadatacopies",
Signature · 1 line
1.6.0.6
cover : Add implicit pvcreate support in vgcreate / vgextend.
In reply to Dave WysochanskiQuoted 6 lines · Dave Wysochanski
This patch set is a rebase and rewrite of the earlier implicit pvcreate patchset. These patches should address most, if not all, feedback to date, and include updated tests. Once these patches are in, a user should no longer need pvcreate, except in rare recovery scenarios (usage of --uuid, --restorefile, and --physicalvolumesize are not supported with vgcreate and vgextend).
Ack to the complete set.
Alasdair