From 9e111ef67a5ccd5b88c4f20077747a57fba09eba Mon Sep 17 00:00:00 2001 From: Dave Wysochanski Date: Mon, 28 Jun 2010 20:38:23 +0000 Subject: [PATCH] Add --vgmetadatacopies to vgcreate man page, command, and lvm.conf. Allow parsing of --vgmetadatacopies for vgcreate. Accept --metadatacopies as a synonym for --vgmetadatacopies. Signed-off-by: Dave Wysochanski --- man/lvm.conf.5.in | 22 +++++++++++++++++++++- man/vgcreate.8.in | 27 ++++++++++++++++++++------- tools/commands.h | 5 +++-- tools/toollib.c | 12 ++++++++++++ tools/vgcreate.c | 8 ++------ 5 files changed, 58 insertions(+), 16 deletions(-) diff --git a/man/lvm.conf.5.in b/man/lvm.conf.5.in index 02ebb2a09..88f3ab352 100644 --- a/man/lvm.conf.5.in +++ b/man/lvm.conf.5.in @@ -386,7 +386,7 @@ to store on each physical volume. Currently it can be set to 0, 1 or 2. The default is 1. If set to 2, one copy is placed at the beginning of the disk and the other is placed at the end. -It can be overridden on the command line with \fB--metadatacopies\fP. +It can be overridden on the command line with \fB--pvmetadatacopies\fP. If creating a volume group with just one physical volume, it's a good idea to have 2 copies. If creating a large volume group with many physical volumes, you may decide that 3 copies of the metadata @@ -406,6 +406,26 @@ The metadata areas are treated as circular buffers, so unused space becomes filled with an archive of the most recent previous versions of the metadata. .IP +\fBvgmetadatacopies\fP \(em When creating a volume group using the +LVM2 metadata format, this is the default number of copies of metadata +desired across all the physical volumes in the volume group. If set to +a non-zero value, LVM will automatically set or clear the metadataignore +flag on the physical volumes (see \fBpvchange --metadataignore\fP) in order +to achieve the desired number of metadata copies. An LVM command that +adds or removes physical volumes (for example, \fBvgextend\fP, \fBvgreduce\fP, +\fBvgsplit\fP, or \fBvgmerge\fP), may cause LVM to automatically set or +clear the metadataignore flags. Also, if physical volumes go missing or +reappear, or a new number of copies is explicitly set (see +\fBvgchange --vgmetadatacopies\fP), LVM may adjust the metadataignore flags. +Set \fBvgmetadatacopies\fP to 0 instructs LVM not to set or clear the +metadataignore flags automatically. You may set a value larger than the +sum of all metadata areas on all physical volumes. The value can +be overridden on the command line with \fB--vgmetadatacopies\fP for various +commands (for example, \fBvgcreate\fP and \fBvgchange\fP), and can be +queryied with the \fBvg_mda_copies\fP field of \fBvgs\fP. This option +is useful for volume groups containing large numbers of physical volumes +with metadata as it may be used to minimize metadata read and write overhead. +.IP \fBdirs\fP \(em List of directories holding live copies of LVM2 metadata as text files. These directories must not be on logical volumes. It is possible to use LVM2 with a couple of directories diff --git a/man/vgcreate.8.in b/man/vgcreate.8.in index 06e000693..e3d970e39 100644 --- a/man/vgcreate.8.in +++ b/man/vgcreate.8.in @@ -16,6 +16,8 @@ vgcreate \- create a volume group .RB [ -M | \-\-metadatatype type] .RB [ -p | \-\-maxphysicalvolumes .IR MaxPhysicalVolumes ] +.RB [ \-\-[vg]metadatacopies ] +.IR NumberOfCopies|unmanaged|all ] .RB [ \-s | \-\-physicalextentsize .IR PhysicalExtentSize [ \fBbBsSkKmMgGtTpPeE\fR ]] .RB [ \-t | \-\-test ] @@ -66,13 +68,24 @@ to this volume group. The setting can be changed with \fBvgchange\fP. For volume groups with metadata in lvm1 format, the limit and default value is 255. -If the metadata uses lvm2 format, the default value is 0 -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--pvmetadatacopies 0\fP -as described in \fBpvcreate(8)\fP. +If the metadata uses lvm2 format, the value 0 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--pvmetadatacopies 0\fP as described in +\fBpvcreate(8)\fP, and/or use \fB--vgmetadatacopies\fP. +.TP +.BR \-\-vgmetadatacopies " " \fINumberOfCopies|unmanaged|all\fP +Sets the desired number of metadata copies in the volume group. If set to +a non-zero value, LVM will automatically manage the 'metadataignore' +flags on the physical volumes (see \fBpvchange --metadataignore\fP) in order +to achieve \fINumberOfCopies\fP copies of metadata. If set to \fIunmanaged\fP, +LVM will not automatically manage the 'metadataignore' flags. If set to +\fIall\fP, LVM will first clear all of the 'metadataignore' flags on all +metadata areas in the volume group, then set the value to \fIunmanaged\fP. +The \fBvgmetadatacopies\fP option is useful for volume groups containing +large numbers of physical volumes with metadata as it may be used to +minimize metadata read and write overhead. +The default value is \fIunmanaged\fP. .TP .BR \-s ", " \-\-physicalextentsize " " \fIPhysicalExtentSize\fR[\fBbBsSkKmMgGtTpPeE\fR] Sets the physical extent size on physical volumes of this volume group. diff --git a/tools/commands.h b/tools/commands.h index 62a684be7..8f5ff3a94 100644 --- a/tools/commands.h +++ b/tools/commands.h @@ -776,6 +776,7 @@ xx(vgcreate, "\t[-h|--help]" "\n" "\t[-l|--maxlogicalvolumes MaxLogicalVolumes]" "\n" "\t[-M|--metadatatype 1|2] " "\n" + "\t[--[vg]metadatacopies #copies] " "\n" "\t[-p|--maxphysicalvolumes MaxPhysicalVolumes] " "\n" "\t[-s|--physicalextentsize PhysicalExtentSize[bBsSkKmMgGtTpPeE]] " "\n" "\t[-t|--test] " "\n" @@ -787,8 +788,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, - pvmetadatacopies_ARG, metadatacopies_ARG, dataalignment_ARG, - dataalignmentoffset_ARG) + pvmetadatacopies_ARG, metadatacopies_ARG, vgmetadatacopies_ARG, + dataalignment_ARG, dataalignmentoffset_ARG) xx(vgdisplay, "Display volume group information", diff --git a/tools/toollib.c b/tools/toollib.c index 02b06fdc9..e56a3e583 100644 --- a/tools/toollib.c +++ b/tools/toollib.c @@ -1243,6 +1243,18 @@ int vgcreate_params_set_from_args(struct cmd_context *cmd, return 1; } + if (arg_count(cmd, metadatacopies_ARG)) { + vp_new->metadata_copies = arg_int_value(cmd, metadatacopies_ARG, + DEFAULT_VGMETADATACOPIES); + } else if (arg_count(cmd, vgmetadatacopies_ARG)) { + vp_new->metadata_copies = arg_int_value(cmd, vgmetadatacopies_ARG, + DEFAULT_VGMETADATACOPIES); + } else { + vp_new->metadata_copies = find_config_tree_int(cmd, + "metadata/vgmetadatacopies", + DEFAULT_VGMETADATACOPIES); + } + return 0; } diff --git a/tools/vgcreate.c b/tools/vgcreate.c index 60871457e..3bb500f5d 100644 --- a/tools/vgcreate.c +++ b/tools/vgcreate.c @@ -35,11 +35,6 @@ int vgcreate(struct cmd_context *cmd, int argc, char **argv) argc--; argv++; - if (arg_count(cmd, metadatacopies_ARG)) { - log_error("Invalid option --metadatacopies, " - "use --pvmetadatacopies instead."); - return EINVALID_CMD_LINE; - } pvcreate_params_set_defaults(&pp); if (!pvcreate_params_validate(cmd, argc, argv, &pp)) { return EINVALID_CMD_LINE; @@ -68,7 +63,8 @@ int vgcreate(struct cmd_context *cmd, int argc, char **argv) !vg_set_max_lv(vg, vp_new.max_lv) || !vg_set_max_pv(vg, vp_new.max_pv) || !vg_set_alloc_policy(vg, vp_new.alloc) || - !vg_set_clustered(vg, vp_new.clustered)) + !vg_set_clustered(vg, vp_new.clustered) || + !vg_set_mda_copies(vg, vp_new.metadata_copies)) goto bad_orphan; if (!lock_vol(cmd, VG_ORPHANS, LCK_VG_WRITE)) { -- 2.43.5