1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-03 05:18:29 +03:00

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 for
pv commands, but require --pvmetadatacopies for vg commands.
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).

NOTE: This patch will require --pvmetadatacopies for vgconvert as
--metadatacopies is no longer accepted.
This commit is contained in:
Dave Wysochanski 2009-10-05 20:55:56 +00:00
parent b8a7da0133
commit 0ddb66efba
16 changed files with 58 additions and 35 deletions

View File

@ -1,5 +1,6 @@
Version 2.02.54 - Version 2.02.54 -
===================================== =====================================
Add --pvmetadatacopies for pvcreate, vgcreate, vgextend, vgconvert.
Add implict pvcreate support to vgcreate and vgextend. Add implict pvcreate support to vgcreate and vgextend.
Correct example.conf to indicate that lvm2 not lvm1 is the default format. Correct example.conf to indicate that lvm2 not lvm1 is the default format.
Remove an unused stray LVM1_SUPPORT ifdef. Remove an unused stray LVM1_SUPPORT ifdef.

View File

@ -11,7 +11,7 @@ pvcreate \- initialize a disk or partition for use by LVM
.RB [ \-v | \-\-verbose ] .RB [ \-v | \-\-verbose ]
.RB [ \-\-labelsector ] .RB [ \-\-labelsector ]
.RB [ \-M | \-\-metadatatype type ] .RB [ \-M | \-\-metadatatype type ]
.RB [ \-\-metadatacopies #copies ] .RB [ \-\-[pv]metadatacopies #copies ]
.RB [ \-\-metadatasize size ] .RB [ \-\-metadatasize size ]
.RB [ \-\-dataalignment alignment ] .RB [ \-\-dataalignment alignment ]
.RB [ \-\-dataalignmentoffset alignment_offset ] .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" .BR \-\-dataalignmentoffset " alignment_offset"
Shift the start of the data area by this additional \fBalignment_offset\fP. Shift the start of the data area by this additional \fBalignment_offset\fP.
.TP .TP
.BR \-\-metadatacopies " copies" .BR \-\-[pv]metadatacopies " copies"
The number of metadata areas to set aside on each PV. Currently The number of metadata areas to set aside on each PV. Currently
this can be 0, 1 or 2. this can be 0, 1 or 2.
If set to 2, two copies of the volume group metadata If set to 2, two copies of the volume group metadata

View File

@ -113,7 +113,7 @@ removes this restriction: there is then no limit.
If you have a large number of physical volumes in If you have a large number of physical volumes in
a volume group with metadata in lvm2 format, a volume group with metadata in lvm2 format,
for tool performance reasons, you should consider 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. as described in \fBpvcreate(8)\fP.
.TP .TP
.BR \-s ", " \-\-physicalextentsize " " \fIPhysicalExtentSize\fR[\fBbBsSkKmMgGtTpPeE\fR] .BR \-s ", " \-\-physicalextentsize " " \fIPhysicalExtentSize\fR[\fBbBsSkKmMgGtTpPeE\fR]

View File

@ -9,7 +9,7 @@ vgconvert \- convert volume group metadata format
.RB [ \-v | \-\-verbose ] .RB [ \-v | \-\-verbose ]
.RB [ \-\-labelsector ] .RB [ \-\-labelsector ]
.RB [ \-M | \-\-metadatatype type ] .RB [ \-M | \-\-metadatatype type ]
.RB [ \-\-metadatacopies #copies ] .RB [ \-\-pvmetadatacopies #copies ]
.RB [ \-\-metadatasize size ] .RB [ \-\-metadatasize size ]
.RB [ \-\-version ] .RB [ \-\-version ]
.IR VolumeGroupName " [" VolumeGroupName ...] .IR VolumeGroupName " [" VolumeGroupName ...]

View File

@ -71,7 +71,7 @@ which removes this restriction: there is then no limit.
If you have a large number of physical volumes in If you have a large number of physical volumes in
a volume group with metadata in lvm2 format, a volume group with metadata in lvm2 format,
for tool performance reasons, you should consider 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. as described in \fBpvcreate(8)\fP.
.TP .TP
.BR \-s ", " \-\-physicalextentsize " " \fIPhysicalExtentSize\fR[\fBbBsSkKmMgGtTpPeE\fR] .BR \-s ", " \-\-physicalextentsize " " \fIPhysicalExtentSize\fR[\fBbBsSkKmMgGtTpPeE\fR]
@ -108,7 +108,7 @@ volume group. These options are further described in the pvcreate man page.
.TP .TP
.BR \-\-metadatasize " size" .BR \-\-metadatasize " size"
.TP .TP
.BR \-\-metadatacopies " copies" .BR \-\-pvmetadatacopies " copies"
.TP .TP
.BR \-\-dataalignment " alignment" .BR \-\-dataalignment " alignment"
.TP .TP

View File

@ -42,7 +42,7 @@ volume group. These options are further described in the pvcreate man page.
.TP .TP
.BR \-\-metadatasize " size" .BR \-\-metadatasize " size"
.TP .TP
.BR \-\-metadatacopies " copies" .BR \-\-pvmetadatacopies " copies"
.TP .TP
.BR \-\-dataalignment " alignment" .BR \-\-dataalignment " alignment"
.TP .TP

View File

@ -46,15 +46,18 @@ vgremove -ff $vg
not pvcreate --metadatacopies -1 $dev1 not pvcreate --metadatacopies -1 $dev1
#COMM 'pvcreate accepts metadatacopies = 0, 1, 2' #COMM 'pvcreate accepts metadatacopies = 0, 1, 2'
pvcreate --metadatacopies 0 $dev1 for j in metadatacopies pvmetadatacopies
pvcreate --metadatacopies 1 $dev2 do
pvcreate --metadatacopies 2 $dev3 pvcreate --$j 0 $dev1
pvcreate --$j 1 $dev2
pvcreate --$j 2 $dev3
check_pv_field_ $dev1 pv_mda_count 0 check_pv_field_ $dev1 pv_mda_count 0
check_pv_field_ $dev2 pv_mda_count 1 check_pv_field_ $dev2 pv_mda_count 1
check_pv_field_ $dev3 pv_mda_count 2 check_pv_field_ $dev3 pv_mda_count 2
pvremove $dev1 pvremove $dev1
pvremove $dev2 pvremove $dev2
pvremove $dev3 pvremove $dev3
done
#COMM 'pvcreate rejects metadatacopies > 2' #COMM 'pvcreate rejects metadatacopies > 2'
not pvcreate --metadatacopies 3 $dev1 not pvcreate --metadatacopies 3 $dev1

View File

@ -105,17 +105,17 @@ do
pvremove -f $dev1 pvremove -f $dev1
done done
# metadatacopies # pvmetadatacopies
for i in 1 2 for i in 1 2
do do
vgcreate --metadatacopies $i $vg $dev1 vgcreate --pvmetadatacopies $i $vg $dev1
check_pv_field_ $dev1 pv_mda_count $i check_pv_field_ $dev1 pv_mda_count $i
vgremove -f $vg vgremove -f $vg
pvremove -f $dev1 pvremove -f $dev1
done done
not vgcreate --metadatacopies 0 $vg $dev1 not vgcreate --metadatacopies 0 $vg $dev1
pvcreate --metadatacopies 1 $dev2 pvcreate --metadatacopies 1 $dev2
vgcreate --metadatacopies 0 $vg $dev1 $dev2 vgcreate --pvmetadatacopies 0 $vg $dev1 $dev2
check_pv_field_ $dev1 pv_mda_count 0 check_pv_field_ $dev1 pv_mda_count 0
check_pv_field_ $dev2 pv_mda_count 1 check_pv_field_ $dev2 pv_mda_count 1
vgremove -f $vg vgremove -f $vg

View File

@ -51,10 +51,10 @@ do
pvremove -f $dev1 pvremove -f $dev1
done done
# metadatacopies # pvmetadatacopies
for i in 0 1 2 for i in 0 1 2
do do
vgextend --metadatacopies $i $vg $dev1 vgextend --pvmetadatacopies $i $vg $dev1
check_pv_field_ $dev1 pv_mda_count $i check_pv_field_ $dev1 pv_mda_count $i
vgreduce $vg $dev1 vgreduce $vg $dev1
pvremove -f $dev1 pvremove -f $dev1

View File

@ -23,6 +23,7 @@ arg(quiet_ARG, '\0', "quiet", NULL, 0)
arg(physicalvolumesize_ARG, '\0', "setphysicalvolumesize", size_mb_arg, 0) arg(physicalvolumesize_ARG, '\0', "setphysicalvolumesize", size_mb_arg, 0)
arg(ignorelockingfailure_ARG, '\0', "ignorelockingfailure", NULL, 0) arg(ignorelockingfailure_ARG, '\0', "ignorelockingfailure", NULL, 0)
arg(nolocking_ARG, '\0', "nolocking", 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(metadatacopies_ARG, '\0', "metadatacopies", int_arg, 0)
arg(metadatasize_ARG, '\0', "metadatasize", size_mb_arg, 0) arg(metadatasize_ARG, '\0', "metadatasize", size_mb_arg, 0)
arg(restorefile_ARG, '\0', "restorefile", string_arg, 0) arg(restorefile_ARG, '\0', "restorefile", string_arg, 0)

View File

@ -479,7 +479,7 @@ xx(pvcreate,
"\t[-h|-?|--help] " "\n" "\t[-h|-?|--help] " "\n"
"\t[--labelsector sector] " "\n" "\t[--labelsector sector] " "\n"
"\t[-M|--metadatatype 1|2]" "\n" "\t[-M|--metadatatype 1|2]" "\n"
"\t[--metadatacopies #copies]" "\n" "\t[--pvmetadatacopies #copies]" "\n"
"\t[--metadatasize MetadataSize[bBsSkKmMgGtTpPeE]]" "\n" "\t[--metadatasize MetadataSize[bBsSkKmMgGtTpPeE]]" "\n"
"\t[--dataalignment Alignment[bBsSkKmMgGtTpPeE]]" "\n" "\t[--dataalignment Alignment[bBsSkKmMgGtTpPeE]]" "\n"
"\t[--dataalignmentoffset AlignmentOffset[bBsSkKmMgGtTpPeE]]" "\n" "\t[--dataalignmentoffset AlignmentOffset[bBsSkKmMgGtTpPeE]]" "\n"
@ -493,8 +493,9 @@ xx(pvcreate,
"\tPhysicalVolume [PhysicalVolume...]\n", "\tPhysicalVolume [PhysicalVolume...]\n",
dataalignment_ARG, dataalignmentoffset_ARG, force_ARG, test_ARG, dataalignment_ARG, dataalignmentoffset_ARG, force_ARG, test_ARG,
labelsector_ARG, metadatatype_ARG, metadatacopies_ARG, metadatasize_ARG, labelsector_ARG, metadatatype_ARG, metadatacopies_ARG, pvmetadatacopies_ARG,
physicalvolumesize_ARG, restorefile_ARG, uuidstr_ARG, yes_ARG, zero_ARG) metadatasize_ARG, physicalvolumesize_ARG, restorefile_ARG, uuidstr_ARG,
yes_ARG, zero_ARG)
xx(pvdata, xx(pvdata,
"Display the on-disk metadata for physical volume(s)", "Display the on-disk metadata for physical volume(s)",
@ -727,7 +728,7 @@ xx(vgconvert,
"\t[-h|--help] " "\n" "\t[-h|--help] " "\n"
"\t[--labelsector sector] " "\n" "\t[--labelsector sector] " "\n"
"\t[-M|--metadatatype 1|2]" "\n" "\t[-M|--metadatatype 1|2]" "\n"
"\t[--metadatacopies #copies]" "\n" "\t[--pvmetadatacopies #copies]" "\n"
"\t[--metadatasize MetadataSize[bBsSkKmMgGtTpPeE]]" "\n" "\t[--metadatasize MetadataSize[bBsSkKmMgGtTpPeE]]" "\n"
"\t[-t|--test] " "\n" "\t[-t|--test] " "\n"
"\t[-v|--verbose] " "\n" "\t[-v|--verbose] " "\n"
@ -735,7 +736,7 @@ xx(vgconvert,
"\tVolumeGroupName [VolumeGroupName...]\n", "\tVolumeGroupName [VolumeGroupName...]\n",
force_ARG, test_ARG, labelsector_ARG, metadatatype_ARG, metadatacopies_ARG, force_ARG, test_ARG, labelsector_ARG, metadatatype_ARG, metadatacopies_ARG,
metadatasize_ARG ) pvmetadatacopies_ARG, metadatasize_ARG )
xx(vgcreate, xx(vgcreate,
"Create a volume group", "Create a volume group",
@ -760,7 +761,8 @@ xx(vgcreate,
addtag_ARG, alloc_ARG, autobackup_ARG, clustered_ARG, maxlogicalvolumes_ARG, 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, 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, xx(vgdisplay,
"Display volume group information", "Display volume group information",
@ -826,8 +828,8 @@ xx(vgextend,
autobackup_ARG, test_ARG, autobackup_ARG, test_ARG,
force_ARG, yes_ARG, zero_ARG, labelsector_ARG, metadatatype_ARG, force_ARG, yes_ARG, zero_ARG, labelsector_ARG, metadatatype_ARG,
metadatasize_ARG, metadatacopies_ARG, dataalignment_ARG, metadatasize_ARG, pvmetadatacopies_ARG, metadatacopies_ARG,
dataalignmentoffset_ARG) dataalignment_ARG, dataalignmentoffset_ARG)
xx(vgimport, xx(vgimport,
"Register exported volume group with system", "Register exported volume group with system",

View File

@ -837,7 +837,8 @@ static int _get_settings(struct cmd_context *cmd)
if (!_merge_synonym(cmd, resizable_ARG, resizeable_ARG) || if (!_merge_synonym(cmd, resizable_ARG, resizeable_ARG) ||
!_merge_synonym(cmd, allocation_ARG, allocatable_ARG) || !_merge_synonym(cmd, allocation_ARG, allocatable_ARG) ||
!_merge_synonym(cmd, allocation_ARG, resizeable_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; return EINVALID_CMD_LINE;
/* Zero indicates success */ /* Zero indicates success */

View File

@ -1305,7 +1305,7 @@ int pvcreate_validate_params(struct cmd_context *cmd,
} }
if (!(cmd->fmt->features & FMT_MDAS) && if (!(cmd->fmt->features & FMT_MDAS) &&
(arg_count(cmd, metadatacopies_ARG) || (arg_count(cmd, pvmetadatacopies_ARG) ||
arg_count(cmd, metadatasize_ARG) || arg_count(cmd, metadatasize_ARG) ||
arg_count(cmd, dataalignment_ARG) || arg_count(cmd, dataalignment_ARG) ||
arg_count(cmd, dataalignmentoffset_ARG))) { arg_count(cmd, dataalignmentoffset_ARG))) {
@ -1314,8 +1314,8 @@ int pvcreate_validate_params(struct cmd_context *cmd,
return 0; return 0;
} }
if (arg_count(cmd, metadatacopies_ARG) && if (arg_count(cmd, pvmetadatacopies_ARG) &&
arg_int_value(cmd, metadatacopies_ARG, -1) > 2) { arg_int_value(cmd, pvmetadatacopies_ARG, -1) > 2) {
log_error("Metadatacopies may only be 0, 1 or 2"); log_error("Metadatacopies may only be 0, 1 or 2");
return 0; return 0;
} }
@ -1371,7 +1371,7 @@ int pvcreate_validate_params(struct cmd_context *cmd,
"metadata/pvmetadatasize", "metadata/pvmetadatasize",
DEFAULT_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) if (pp->pvmetadatacopies < 0)
pp->pvmetadatacopies = find_config_tree_int(cmd, pp->pvmetadatacopies = find_config_tree_int(cmd,
"metadata/pvmetadatacopies", "metadata/pvmetadatacopies",

View File

@ -57,7 +57,7 @@ static int vgconvert_single(struct cmd_context *cmd, const char *vg_name,
"metadata/pvmetadatasize", "metadata/pvmetadatasize",
DEFAULT_PVMETADATASIZE); DEFAULT_PVMETADATASIZE);
pvmetadatacopies = arg_int_value(cmd, metadatacopies_ARG, -1); pvmetadatacopies = arg_int_value(cmd, pvmetadatacopies_ARG, -1);
if (pvmetadatacopies < 0) if (pvmetadatacopies < 0)
pvmetadatacopies = pvmetadatacopies =
find_config_tree_int(cmd, find_config_tree_int(cmd,
@ -211,15 +211,20 @@ int vgconvert(struct cmd_context *cmd, int argc, char **argv)
return EINVALID_CMD_LINE; return EINVALID_CMD_LINE;
} }
if (arg_count(cmd, metadatacopies_ARG)) {
log_error("Invalid option --metadatacopies, "
"use --pvmetadatacopies instead.");
return EINVALID_CMD_LINE;
}
if (!(cmd->fmt->features & FMT_MDAS) && if (!(cmd->fmt->features & FMT_MDAS) &&
(arg_count(cmd, metadatacopies_ARG) || (arg_count(cmd, pvmetadatacopies_ARG) ||
arg_count(cmd, metadatasize_ARG))) { arg_count(cmd, metadatasize_ARG))) {
log_error("Metadata parameters only apply to text format"); log_error("Metadata parameters only apply to text format");
return EINVALID_CMD_LINE; return EINVALID_CMD_LINE;
} }
if (arg_count(cmd, metadatacopies_ARG) && if (arg_count(cmd, pvmetadatacopies_ARG) &&
arg_int_value(cmd, metadatacopies_ARG, -1) > 2) { arg_int_value(cmd, pvmetadatacopies_ARG, -1) > 2) {
log_error("Metadatacopies may only be 0, 1 or 2"); log_error("Metadatacopies may only be 0, 1 or 2");
return EINVALID_CMD_LINE; return EINVALID_CMD_LINE;
} }

View File

@ -35,6 +35,11 @@ int vgcreate(struct cmd_context *cmd, int argc, char **argv)
argc--; argc--;
argv++; argv++;
if (arg_count(cmd, metadatacopies_ARG)) {
log_error("Invalid option --metadatacopies, "
"use --pvmetadatacopies instead.");
return EINVALID_CMD_LINE;
}
fill_default_pvcreate_params(&pp); fill_default_pvcreate_params(&pp);
if (!pvcreate_validate_params(cmd, argc, argv, &pp)) { if (!pvcreate_validate_params(cmd, argc, argv, &pp)) {
return EINVALID_CMD_LINE; return EINVALID_CMD_LINE;

View File

@ -32,6 +32,11 @@ int vgextend(struct cmd_context *cmd, int argc, char **argv)
argc--; argc--;
argv++; argv++;
if (arg_count(cmd, metadatacopies_ARG)) {
log_error("Invalid option --metadatacopies, "
"use --pvmetadatacopies instead.");
return EINVALID_CMD_LINE;
}
fill_default_pvcreate_params(&pp); fill_default_pvcreate_params(&pp);
if (!pvcreate_validate_params(cmd, argc, argv, &pp)) { if (!pvcreate_validate_params(cmd, argc, argv, &pp)) {
return EINVALID_CMD_LINE; return EINVALID_CMD_LINE;