require --restorefile when using pvcreate --uuid
PATCH 1/2 require --restorefile when using pvcreate --uuid
Introduce --norestorefile to allow user to override the new requirement that --restorefile be supplied when using pvcreate --uuid.
This can also be overridden with "devices/require_restorefile_with_uuid" in lvm.conf -- however the default is 1.
--
doc/example.conf.in | 3 +++ lib/config/defaults.h | 1 + test/t-pvcreate-operation.sh | 11 +++++++---- tools/args.h | 1 + tools/commands.h | 6 ++++-- tools/pvcreate.c | 10 ++++++++++ 6 files changed, 26 insertions(+), 6 deletions(-)
doc/example.conf.in +3 -0
@@ -130,6 +130,9 @@ devices { # Set this to 1 to skip such devices. This should only be needed # in recovery situations. ignore_suspended_devices = 0 + + # Allow use of pvcreate --uuid without requiring --restorefile. + require_restorefile_with_uuid = 1 } # This section that allows you to configure the nature of the
lib/config/defaults.h +1 -0
@@ -30,6 +30,7 @@#define DEFAULT_MD_COMPONENT_DETECTION 1#define DEFAULT_MD_CHUNK_ALIGNMENT 1#define DEFAULT_IGNORE_SUSPENDED_DEVICES 1 +#define DEFAULT_REQUIRE_RESTOREFILE_WITH_UUID 1#define DEFAULT_DATA_ALIGNMENT_OFFSET_DETECTION 1#define DEFAULT_DATA_ALIGNMENT_DETECTION 1
test/t-pvcreate-operation.sh +7 -4
@@ -95,17 +95,20 @@ uuid2=freddy-fred-fred-fred-fred-fred-fredie bogusuuid=fred # pvcreate rejects uuid option with less than 32 characters -not pvcreate --uuid $bogusuuid $dev1 +not pvcreate --norestorefile --uuid $bogusuuid $dev1 + +# pvcreate rejects uuid option without restorefile +not pvcreate --uuid $uuid1 $dev1 # pvcreate rejects uuid already in use -pvcreate --uuid $uuid1 $dev1 -not pvcreate --uuid $uuid1 $dev2 +pvcreate --norestorefile --uuid $uuid1 $dev1 +not pvcreate --norestorefile --uuid $uuid1 $dev2 # pvcreate rejects non-existent file given with restorefile not pvcreate --uuid $uuid1 --restorefile $backupfile $dev1 # pvcreate rejects restorefile with uuid not found in file -pvcreate --uuid $uuid1 $dev1 +pvcreate --norestorefile --uuid $uuid1 $dev1 vgcfgbackup -f $backupfile not pvcreate --uuid $uuid2 --restorefile $backupfile $dev2
tools/args.h +1 -0
@@ -27,6 +27,7 @@ arg(vgmetadatacopies_ARG, '\0', "vgmetadatacopies", metadatacopies_arg, 0) arg(metadatacopies_ARG, '\0', "metadatacopies", metadatacopies_arg, 0) arg(metadatasize_ARG, '\0', "metadatasize", size_mb_arg, 0) arg(metadataignore_ARG, '\0', "metadataignore", yes_no_arg, 0) +arg(norestorefile_ARG, '\0', "norestorefile", NULL, 0) arg(restorefile_ARG, '\0', "restorefile", string_arg, 0) arg(labelsector_ARG, '\0', "labelsector", int_arg, 0)arg (driverloaded_ARG,'\0' ,"driverloaded" , yes_no_arg,0 )
tools/commands.h +4 -2
@@ -497,6 +497,7 @@ xx(pvcreate,"Initialize physical volume(s) for use by LVM" ,0 ,"pvcreate " "\n" +"\t[--norestorefile]\n" "\t[--restorefile file]\n" "\t[-d|--debug]" "\n" "\t[-f[f]|--force [--force]] " "\n"
@@ -517,8 +518,9 @@ xx(pvcreate,"\tPhysicalVolume [PhysicalVolume...]\n" , dataalignment_ARG, dataalignmentoffset_ARG, force_ARG, test_ARG, - labelsector_ARG, metadatatype_ARG, metadatacopies_ARG, pvmetadatacopies_ARG, - metadatasize_ARG, metadataignore_ARG, physicalvolumesize_ARG, + labelsector_ARG, metadatatype_ARG, metadatacopies_ARG, + metadatasize_ARG, metadataignore_ARG, norestorefile_ARG, + physicalvolumesize_ARG, pvmetadatacopies_ARG, restorefile_ARG, uuidstr_ARG, yes_ARG, zero_ARG) xx(pvdata,
tools/pvcreate.c +10 -0
@@ -36,6 +36,16 @@ static int pvcreate_restore_params_validate(struct cmd_context *cmd,return 0 ; } +if (!arg_count (cmd, restorefile_ARG) &&arg_count (cmd, uuidstr_ARG)) { +if (!arg_count (cmd, norestorefile_ARG) && +find_config_tree_bool (cmd, +"devices/require_restorefile_with_uuid" , +DEFAULT_REQUIRE_RESTOREFILE_WITH_UUID )) { +log_error ("--restorefile is required with --uuid" ); +return 0 ; + } + } +if (arg_count (cmd, uuidstr_ARG) && argc !=1 ) {log_error ("Can only set uuid on one volume at once" );return 0 ;
PATCH v3 2/2 change default alignment of pe_start to 1MB
The new standard in the storage industry is to default alignment of data areas to 1MB. fdisk, parted, and mdadm have all been updated to this default.
Update LVM to align the PV's data area start (pe_start) to 1MB. This provides a more useful default than the previous default of 64K (which generally ended up being a 192K pe_start once the first metadata area was created).
Before this patch:
# pvs -o name,vg_mda_size,pe_start PV VMdaSize 1st PE /dev/sdd 188.00k 192.00k
After this patch:
# pvs -o name,vg_mda_size,pe_start PV VMdaSize 1st PE /dev/sdd 1020.00k 1.00m
The heuristic for setting the default alignment for LVM data areas is:
- If the default value (1MB) is a multiple of the detected alignment then just use the default.
- Otherwise, use the detected value.
In practice this means we'll almost always use 1MB -- that is unless:
- the alignment was explicitly specified with --dataalignment
- or MD's full stripe width, or the {minimum,optimal}_io_size exceeds 1MB
- or the specified/detected value is not a power-of-2
--
doc/example.conf.in | 2 +- lib/metadata/metadata.c | 32 +++++++++++++++++++++----------- test/lvm-utils.sh | 3 ++- test/t-pvcreate-operation-md.sh | 23 +++++++++-------------- test/t-pvcreate-usage.sh | 6 +++--- test/t-topology-support.sh | 2 +- test/t-vgcreate-usage.sh | 6 +++--- test/t-vgextend-usage.sh | 6 +++--- test/t-vgsplit-operation.sh | 2 +- test/test-utils.sh | 2 +- 10 files changed, 45 insertions(+), 39 deletions(-)
doc/example.conf.in +1 -1
@@ -113,7 +113,7 @@ devices { # Alignment (in KB) of start of data area when creating a new PV. # If a PV is placed directly upon an md device and md_chunk_alignment or # data_alignment_detection is enabled this parameter is ignored. - # Set to 0 for the default alignment of 64KB or page size, if larger. + # Set to 0 for the default alignment of 1MB or page size, if larger. data_alignment = 0 # By default, the start of the PV's aligned data area will be shifted by
lib/metadata/metadata.c +21 -11
@@ -62,15 +62,24 @@ static uint32_t _vg_bad_status_bits(const struct volume_group *vg,const char _really_init[] ="Really INITIALIZE physical volume \"%s\" of volume group \"%s\" [y/n]? " ; +static int _alignment_overrides_default (unsigned long data_alignment, +unsigned long default_alignment) +{ +return data_alignment && (default_alignment % data_alignment); +} +unsigned long set_pe_align (struct physical_volume *pv,unsigned long data_alignment) { +unsigned long temp_pe_align, default_pe_align =2048 ; +if (pv->pe_align) goto out;if (data_alignment) pv->pe_align = data_alignment;else - pv->pe_align =MAX (65536UL ,lvm_getpagesize ()) >>SECTOR_SHIFT ; + pv->pe_align =MAX ((default_pe_align <<SECTOR_SHIFT ), +lvm_getpagesize ()) >>SECTOR_SHIFT ;if (!pv->dev) goto out;
@@ -79,10 +88,11 @@ unsigned long set_pe_align(struct physical_volume *pv, unsigned long data_alignm* Align to stripe-width of underlying md device if present */ if (find_config_tree_bool (pv->fmt->cmd,"devices/md_chunk_alignment" , -DEFAULT_MD_CHUNK_ALIGNMENT )) - pv->pe_align =MAX (pv->pe_align, -dev_md_stripe_width (pv->fmt->cmd->sysfs_dir, - pv->dev)); +DEFAULT_MD_CHUNK_ALIGNMENT )) { + temp_pe_align =dev_md_stripe_width (pv->fmt->cmd->sysfs_dir, pv->dev); +if (_alignment_overrides_default (temp_pe_align, default_pe_align)) + pv->pe_align = temp_pe_align; + }/* * Align to topology's minimum_io_size or optimal_io_size if present
@@ -94,13 +104,13 @@ unsigned long set_pe_align(struct physical_volume *pv, unsigned long data_alignmif (find_config_tree_bool (pv->fmt->cmd,"devices/data_alignment_detection" ,DEFAULT_DATA_ALIGNMENT_DETECTION )) { - pv->pe_align =MAX (pv->pe_align, -dev_minimum_io_size (pv->fmt->cmd->sysfs_dir, - pv->dev)); + temp_pe_align =dev_minimum_io_size (pv->fmt->cmd->sysfs_dir, pv->dev); +if (_alignment_overrides_default (temp_pe_align, default_pe_align)) + pv->pe_align = temp_pe_align; - pv->pe_align =MAX (pv->pe_align, -dev_optimal_io_size (pv->fmt->cmd->sysfs_dir, - pv->dev)); + temp_pe_align =dev_optimal_io_size (pv->fmt->cmd->sysfs_dir, pv->dev); +if (_alignment_overrides_default (temp_pe_align, default_pe_align)) + pv->pe_align = temp_pe_align; } log_very_verbose("%s: Setting PE alignment to %lu sectors.",
test/lvm-utils.sh +2 -1
@@ -103,9 +103,10 @@ check_pv_field_() local pv=$1; local field=$2; local expected=$3; + local pvs_args=$4; # optional local actual; - actual=$(trim $(pvs --noheadings -o $field $pv)) + actual=$(trim $(pvs --noheadings $pvs_args -o $field $pv)) if test "$verbose" = "t" then echo "check_pv_field_ PV=$pv, field=$field, actual=$actual, expected=$expected"
test/t-pvcreate-operation-md.sh +9 -14
@@ -52,14 +52,14 @@ test -b "$mddev" || exit 200 # Test alignment of PV on MD without any MD-aware or topology-aware detection # - should treat $mddev just like any other block device -pv_align="192.00k" +pv_align="1.00m" pvcreate --metadatasize 128k \ --config 'devices {md_chunk_alignment=0 data_alignment_detection=0 data_alignment_offset_detection=0}' \ $mddev check_pv_field_ $mddev pe_start $pv_align # Test md_chunk_alignment independent of topology-aware detection -pv_align="256.00k" +pv_align="1.00m" pvcreate --metadatasize 128k \ --config 'devices {data_alignment_detection=0 data_alignment_offset_detection=0}' \ $mddev
@@ -71,7 +71,8 @@ linux_minor=$(echo `uname -r` | cut -d'.' -f3 | cut -d'-' -f1) # Test newer topology-aware alignment detection # - first added to 2.6.31 but not "reliable" until 2.6.33 if [ $linux_minor -ge 33 ]; then - pv_align="256.00k" + pv_align="1.00m" + # optimal_io_size=131072, minimum_io_size=65536 pvcreate --metadatasize 128k \ --config 'devices { md_chunk_alignment=0 }' $mddev check_pv_field_ $mddev pe_start $pv_align
@@ -103,15 +104,9 @@ EOF alignment_offset=`cat $sysfs_alignment_offset` || \ alignment_offset=0 - if [ "$alignment_offset" = "512" ]; then - pv_align="256.50k" - pvcreate --metadatasize 128k $mddev_p - check_pv_field_ $mddev_p pe_start $pv_align - pvremove $mddev_p - elif [ "$alignment_offset" = "2048" ]; then - pv_align="258.00k" - pvcreate --metadatasize 128k $mddev_p - check_pv_field_ $mddev_p pe_start $pv_align - pvremove $mddev_p - fi + # default alignment is 1M, add alignment_offset + pv_align=$((1048576+$alignment_offset))B + pvcreate --metadatasize 128k $mddev_p + check_pv_field_ $mddev_p pe_start $pv_align "--units b" + pvremove $mddev_p fi
test/t-pvcreate-usage.sh +3 -3
@@ -119,11 +119,11 @@ check_pv_field_ $dev1 pe_start $pv_align pvcreate --metadatasize 128k --metadatacopies 2 --dataalignment 3.5k $dev1 check_pv_field_ $dev1 pe_start $pv_align -# data area is aligned to 64k by default, +# data area is aligned to 1M by default, # data area start is shifted by the specified alignment_offset -pv_align="195.50k" +pv_align="1052160B" # 1048576 + (7*512) pvcreate --metadatasize 128k --dataalignmentoffset 7s $dev1 -check_pv_field_ $dev1 pe_start $pv_align +check_pv_field_ $dev1 pe_start $pv_align "--units b" # 2nd metadata area is created without problems when # data area start is shifted by the specified alignment_offset
test/t-topology-support.sh +1 -1
@@ -57,7 +57,7 @@ test_snapshot_mount() # FIXME add more topology-specific tests and validation (striped LVs, etc) NUM_DEVS=1 -PER_DEV_SIZE=33 +PER_DEV_SIZE=34 DEV_SIZE=$(($NUM_DEVS*$PER_DEV_SIZE)) # ---------------------------------------------
test/t-vgcreate-usage.sh +3 -3
@@ -130,11 +130,11 @@ check_pv_field_ $dev1 pe_start 200.00k vgremove -f $vg pvremove -f $dev1 -# data area is aligned to 64k by default, +# data area is aligned to 1M by default, # data area start is shifted by the specified alignment_offset -pv_align="195.50k" +pv_align="1052160B" # 1048576 + (7*512) vgcreate -c n --metadatasize 128k --dataalignmentoffset 7s $vg $dev1 -check_pv_field_ $dev1 pe_start $pv_align +check_pv_field_ $dev1 pe_start $pv_align "--units b" vgremove -f $vg pvremove -f $dev1
test/t-vgextend-usage.sh +3 -3
@@ -67,11 +67,11 @@ check_pv_field_ $dev1 pe_start 200.00k vgreduce $vg $dev1 pvremove -f $dev1 -# data area is aligned to 64k by default, +# data area is aligned to 1M by default, # data area start is shifted by the specified alignment_offset -pv_align="195.50k" +pv_align="1052160B" # 1048576 + (7*512) vgextend --metadatasize 128k --dataalignmentoffset 7s $vg $dev1 -check_pv_field_ $dev1 pe_start $pv_align +check_pv_field_ $dev1 pe_start $pv_align "--units b" vgremove -f $vg pvremove -f $dev1
test/t-vgsplit-operation.sh +1 -1
@@ -17,7 +17,7 @@ COMM() { LAST_TEST="$@" } -prepare_pvs 5 257 +prepare_pvs 5 258 # FIXME: paramaterize lvm1 vs lvm2 metadata; most of these tests should run # fine with lvm1 metadata as well; for now, just add disks 5 and 6 as lvm1 # metadata
test/test-utils.sh +1 -1
@@ -264,7 +264,7 @@ prepare_devs() { local n="$1" test -z "$n" && n=3 local devsize="$2" - test -z "$devsize" && devsize=33 + test -z "$devsize" && devsize=34 local pvname="$3" test -z "$pvname" && pvname="pv"
PATCH v4 2/2 change default alignment of pe_start to 1MB
The new standard in the storage industry is to default alignment of data areas to 1MB. fdisk, parted, and mdadm have all been updated to this default.
Update LVM to align the PV's data area start (pe_start) to 1MB. This provides a more useful default than the previous default of 64K (which generally ended up being a 192K pe_start once the first metadata area was created).
Before this patch:
# pvs -o name,vg_mda_size,pe_start PV VMdaSize 1st PE /dev/sdd 188.00k 192.00k
After this patch:
# pvs -o name,vg_mda_size,pe_start PV VMdaSize 1st PE /dev/sdd 1020.00k 1.00m
The heuristic for setting the default alignment for LVM data areas is:
- If the default value (1MB) is a multiple of the detected alignment then just use the default.
- Otherwise, use the detected value.
In practice this means we'll almost always use 1MB -- that is unless:
- the alignment was explicitly specified with --dataalignment
- or MD's full stripe width, or the {minimum,optimal}_io_size exceeds 1MB
- or the specified/detected value is not a power-of-2
--
doc/example.conf.in | 2 +- lib/config/defaults.h | 2 ++ lib/metadata/metadata.c | 33 +++++++++++++++++++++------------ test/lvm-utils.sh | 3 ++- test/t-pvcreate-operation-md.sh | 23 +++++++++-------------- test/t-pvcreate-usage.sh | 6 +++--- test/t-topology-support.sh | 2 +- test/t-vgcreate-usage.sh | 6 +++--- test/t-vgextend-usage.sh | 6 +++--- test/t-vgsplit-operation.sh | 2 +- test/test-utils.sh | 2 +- 11 files changed, 47 insertions(+), 40 deletions(-)
doc/example.conf.in +1 -1
@@ -113,7 +113,7 @@ devices { # Alignment (in KB) of start of data area when creating a new PV. # If a PV is placed directly upon an md device and md_chunk_alignment or # data_alignment_detection is enabled this parameter is ignored. - # Set to 0 for the default alignment of 64KB or page size, if larger. + # Set to 0 for the default alignment of 1MB or page size, if larger. data_alignment = 0 # By default, the start of the PV's aligned data area will be shifted by
lib/metadata/metadata.c +21 -12
@@ -62,15 +62,23 @@ static uint32_t _vg_bad_status_bits(consconst char _really_init[] ="Really INITIALIZE physical volume \"%s\" of volume group \"%s\" [y/n]? " ; +static int _alignment_overrides_default (unsigned long data_alignment) +{ +return data_alignment && (DEFAULT_PE_ALIGN % data_alignment); +} +unsigned long set_pe_align (struct physical_volume *pv,unsigned long data_alignment) { +unsigned long temp_pe_align; +if (pv->pe_align) goto out;if (data_alignment) pv->pe_align = data_alignment;else - pv->pe_align =MAX (65536UL ,lvm_getpagesize ()) >>SECTOR_SHIFT ; + pv->pe_align =MAX ((DEFAULT_PE_ALIGN <<SECTOR_SHIFT ), +lvm_getpagesize ()) >>SECTOR_SHIFT ;if (!pv->dev) goto out;
@@ -79,10 +87,11 @@ unsigned long set_pe_align(struct physic* Align to stripe-width of underlying md device if present */ if (find_config_tree_bool (pv->fmt->cmd,"devices/md_chunk_alignment" , -DEFAULT_MD_CHUNK_ALIGNMENT )) - pv->pe_align =MAX (pv->pe_align, -dev_md_stripe_width (pv->fmt->cmd->sysfs_dir, - pv->dev)); +DEFAULT_MD_CHUNK_ALIGNMENT )) { + temp_pe_align =dev_md_stripe_width (pv->fmt->cmd->sysfs_dir, pv->dev); +if (_alignment_overrides_default (temp_pe_align)) + pv->pe_align = temp_pe_align; + }/* * Align to topology's minimum_io_size or optimal_io_size if present
@@ -94,13 +103,13 @@ unsigned long set_pe_align(struct physicif (find_config_tree_bool (pv->fmt->cmd,"devices/data_alignment_detection" ,DEFAULT_DATA_ALIGNMENT_DETECTION )) { - pv->pe_align =MAX (pv->pe_align, -dev_minimum_io_size (pv->fmt->cmd->sysfs_dir, - pv->dev)); - - pv->pe_align =MAX (pv->pe_align, -dev_optimal_io_size (pv->fmt->cmd->sysfs_dir, - pv->dev)); + temp_pe_align =dev_minimum_io_size (pv->fmt->cmd->sysfs_dir, pv->dev); +if (_alignment_overrides_default (temp_pe_align)) + pv->pe_align = temp_pe_align; + + temp_pe_align =dev_optimal_io_size (pv->fmt->cmd->sysfs_dir, pv->dev); +if (_alignment_overrides_default (temp_pe_align)) + pv->pe_align = temp_pe_align; } log_very_verbose("%s: Setting PE alignment to %lu sectors.",
test/lvm-utils.sh +2 -1
@@ -103,9 +103,10 @@ check_pv_field_() local pv=$1; local field=$2; local expected=$3; + local pvs_args=$4; # optional local actual; - actual=$(trim $(pvs --noheadings -o $field $pv)) + actual=$(trim $(pvs --noheadings $pvs_args -o $field $pv)) if test "$verbose" = "t" then echo "check_pv_field_ PV=$pv, field=$field, actual=$actual, expected=$expected"
test/t-pvcreate-operation-md.sh +9 -14
@@ -52,14 +52,14 @@ test -b "$mddev" || exit 200 # Test alignment of PV on MD without any MD-aware or topology-aware detection # - should treat $mddev just like any other block device -pv_align="192.00k" +pv_align="1.00m" pvcreate --metadatasize 128k \ --config 'devices {md_chunk_alignment=0 data_alignment_detection=0 data_alignment_offset_detection=0}' \ $mddev check_pv_field_ $mddev pe_start $pv_align # Test md_chunk_alignment independent of topology-aware detection -pv_align="256.00k" +pv_align="1.00m" pvcreate --metadatasize 128k \ --config 'devices {data_alignment_detection=0 data_alignment_offset_detection=0}' \ $mddev
@@ -71,7 +71,8 @@ linux_minor=$(echo `uname -r` | cut -d'. # Test newer topology-aware alignment detection # - first added to 2.6.31 but not "reliable" until 2.6.33 if [ $linux_minor -ge 33 ]; then - pv_align="256.00k" + pv_align="1.00m" + # optimal_io_size=131072, minimum_io_size=65536 pvcreate --metadatasize 128k \ --config 'devices { md_chunk_alignment=0 }' $mddev check_pv_field_ $mddev pe_start $pv_align
@@ -103,15 +104,9 @@ EOF alignment_offset=`cat $sysfs_alignment_offset` || \ alignment_offset=0 - if [ "$alignment_offset" = "512" ]; then - pv_align="256.50k" - pvcreate --metadatasize 128k $mddev_p - check_pv_field_ $mddev_p pe_start $pv_align - pvremove $mddev_p - elif [ "$alignment_offset" = "2048" ]; then - pv_align="258.00k" - pvcreate --metadatasize 128k $mddev_p - check_pv_field_ $mddev_p pe_start $pv_align - pvremove $mddev_p - fi + # default alignment is 1M, add alignment_offset + pv_align=$((1048576+$alignment_offset))B + pvcreate --metadatasize 128k $mddev_p + check_pv_field_ $mddev_p pe_start $pv_align "--units b" + pvremove $mddev_p fi
test/t-pvcreate-usage.sh +3 -3
@@ -119,11 +119,11 @@ check_pv_field_ $dev1 pe_start $pv_align pvcreate --metadatasize 128k --metadatacopies 2 --dataalignment 3.5k $dev1 check_pv_field_ $dev1 pe_start $pv_align -# data area is aligned to 64k by default, +# data area is aligned to 1M by default, # data area start is shifted by the specified alignment_offset -pv_align="195.50k" +pv_align="1052160B" # 1048576 + (7*512) pvcreate --metadatasize 128k --dataalignmentoffset 7s $dev1 -check_pv_field_ $dev1 pe_start $pv_align +check_pv_field_ $dev1 pe_start $pv_align "--units b" # 2nd metadata area is created without problems when # data area start is shifted by the specified alignment_offset
test/t-topology-support.sh +1 -1
@@ -57,7 +57,7 @@ test_snapshot_mount() # FIXME add more topology-specific tests and validation (striped LVs, etc) NUM_DEVS=1 -PER_DEV_SIZE=33 +PER_DEV_SIZE=34 DEV_SIZE=$(($NUM_DEVS*$PER_DEV_SIZE)) # ---------------------------------------------
test/t-vgcreate-usage.sh +3 -3
@@ -130,11 +130,11 @@ check_pv_field_ $dev1 pe_start 200.00k vgremove -f $vg pvremove -f $dev1 -# data area is aligned to 64k by default, +# data area is aligned to 1M by default, # data area start is shifted by the specified alignment_offset -pv_align="195.50k" +pv_align="1052160B" # 1048576 + (7*512) vgcreate -c n --metadatasize 128k --dataalignmentoffset 7s $vg $dev1 -check_pv_field_ $dev1 pe_start $pv_align +check_pv_field_ $dev1 pe_start $pv_align "--units b" vgremove -f $vg pvremove -f $dev1
test/t-vgextend-usage.sh +3 -3
@@ -67,11 +67,11 @@ check_pv_field_ $dev1 pe_start 200.00k vgreduce $vg $dev1 pvremove -f $dev1 -# data area is aligned to 64k by default, +# data area is aligned to 1M by default, # data area start is shifted by the specified alignment_offset -pv_align="195.50k" +pv_align="1052160B" # 1048576 + (7*512) vgextend --metadatasize 128k --dataalignmentoffset 7s $vg $dev1 -check_pv_field_ $dev1 pe_start $pv_align +check_pv_field_ $dev1 pe_start $pv_align "--units b" vgremove -f $vg pvremove -f $dev1
test/t-vgsplit-operation.sh +1 -1
@@ -17,7 +17,7 @@ COMM() { LAST_TEST="$@" } -prepare_pvs 5 257 +prepare_pvs 5 258 # FIXME: paramaterize lvm1 vs lvm2 metadata; most of these tests should run # fine with lvm1 metadata as well; for now, just add disks 5 and 6 as lvm1 # metadata
test/test-utils.sh +1 -1
@@ -264,7 +264,7 @@ prepare_devs() { local n="$1" test -z "$n" && n=3 local devsize="$2" - test -z "$devsize" && devsize=33 + test -z "$devsize" && devsize=34 local pvname="$3" test -z "$pvname" && pvname="pv"
lib/config/defaults.h +2 -0
@@ -16,6 +16,8 @@#ifndef _LVM_DEFAULTS_H#define _LVM_DEFAULTS_H +#define DEFAULT_PE_ALIGN 2048 +#define DEFAULT_ARCHIVE_ENABLED 1#define DEFAULT_BACKUP_ENABLED 1
PATCH v5 2/2 change default alignment of pe_start to 1MB
The new standard in the storage industry is to default alignment of data areas to 1MB. fdisk, parted, and mdadm have all been updated to this default.
Update LVM to align the PV's data area start (pe_start) to 1MB. This provides a more useful default than the previous default of 64K (which generally ended up being a 192K pe_start once the first metadata area was created).
Before this patch:
# pvs -o name,vg_mda_size,pe_start PV VMdaSize 1st PE /dev/sdd 188.00k 192.00k
After this patch:
# pvs -o name,vg_mda_size,pe_start PV VMdaSize 1st PE /dev/sdd 1020.00k 1.00m
The heuristic for setting the default alignment for LVM data areas is:
- If the default value (1MB) is a multiple of the detected alignment then just use the default.
- Otherwise, use the detected value.
In practice this means we'll almost always use 1MB -- that is unless:
- the alignment was explicitly specified with --dataalignment
- or MD's full stripe width, or the {minimum,optimal}_io_size exceeds 1MB
- or the specified/detected value is not a power-of-2
--
doc/example.conf.in | 2 +- lib/config/defaults.h | 2 ++ lib/metadata/metadata.c | 33 +++++++++++++++++++++------------ test/lvm-utils.sh | 3 ++- test/t-covercmd.sh | 2 +- test/t-pvcreate-operation-md.sh | 23 +++++++++-------------- test/t-pvcreate-usage.sh | 6 +++--- test/t-topology-support.sh | 2 +- test/t-vgcreate-usage.sh | 6 +++--- test/t-vgextend-usage.sh | 6 +++--- test/t-vgsplit-operation.sh | 2 +- test/test-utils.sh | 2 +- 12 files changed, 48 insertions(+), 41 deletions(-)
doc/example.conf.in +1 -1
@@ -113,7 +113,7 @@ devices { # Alignment (in KB) of start of data area when creating a new PV. # If a PV is placed directly upon an md device and md_chunk_alignment or # data_alignment_detection is enabled this parameter is ignored. - # Set to 0 for the default alignment of 64KB or page size, if larger. + # Set to 0 for the default alignment of 1MB or page size, if larger. data_alignment = 0 # By default, the start of the PV's aligned data area will be shifted by
lib/metadata/metadata.c +21 -12
@@ -62,15 +62,23 @@ static uint32_t _vg_bad_status_bits(consconst char _really_init[] ="Really INITIALIZE physical volume \"%s\" of volume group \"%s\" [y/n]? " ; +static int _alignment_overrides_default (unsigned long data_alignment) +{ +return data_alignment && (DEFAULT_PE_ALIGN % data_alignment); +} +unsigned long set_pe_align (struct physical_volume *pv,unsigned long data_alignment) { +unsigned long temp_pe_align; +if (pv->pe_align) goto out;if (data_alignment) pv->pe_align = data_alignment;else - pv->pe_align =MAX (65536UL ,lvm_getpagesize ()) >>SECTOR_SHIFT ; + pv->pe_align =MAX ((DEFAULT_PE_ALIGN <<SECTOR_SHIFT ), +lvm_getpagesize ()) >>SECTOR_SHIFT ;if (!pv->dev) goto out;
@@ -79,10 +87,11 @@ unsigned long set_pe_align(struct physic* Align to stripe-width of underlying md device if present */ if (find_config_tree_bool (pv->fmt->cmd,"devices/md_chunk_alignment" , -DEFAULT_MD_CHUNK_ALIGNMENT )) - pv->pe_align =MAX (pv->pe_align, -dev_md_stripe_width (pv->fmt->cmd->sysfs_dir, - pv->dev)); +DEFAULT_MD_CHUNK_ALIGNMENT )) { + temp_pe_align =dev_md_stripe_width (pv->fmt->cmd->sysfs_dir, pv->dev); +if (_alignment_overrides_default (temp_pe_align)) + pv->pe_align = temp_pe_align; + }/* * Align to topology's minimum_io_size or optimal_io_size if present
@@ -94,13 +103,13 @@ unsigned long set_pe_align(struct physicif (find_config_tree_bool (pv->fmt->cmd,"devices/data_alignment_detection" ,DEFAULT_DATA_ALIGNMENT_DETECTION )) { - pv->pe_align =MAX (pv->pe_align, -dev_minimum_io_size (pv->fmt->cmd->sysfs_dir, - pv->dev)); - - pv->pe_align =MAX (pv->pe_align, -dev_optimal_io_size (pv->fmt->cmd->sysfs_dir, - pv->dev)); + temp_pe_align =dev_minimum_io_size (pv->fmt->cmd->sysfs_dir, pv->dev); +if (_alignment_overrides_default (temp_pe_align)) + pv->pe_align = temp_pe_align; + + temp_pe_align =dev_optimal_io_size (pv->fmt->cmd->sysfs_dir, pv->dev); +if (_alignment_overrides_default (temp_pe_align)) + pv->pe_align = temp_pe_align; } log_very_verbose("%s: Setting PE alignment to %lu sectors.",
test/lvm-utils.sh +2 -1
@@ -103,9 +103,10 @@ check_pv_field_() local pv=$1; local field=$2; local expected=$3; + local pvs_args=$4; # optional local actual; - actual=$(trim $(pvs --noheadings -o $field $pv)) + actual=$(trim $(pvs --noheadings $pvs_args -o $field $pv)) if test "$verbose" = "t" then echo "check_pv_field_ PV=$pv, field=$field, actual=$actual, expected=$expected"
test/t-pvcreate-operation-md.sh +9 -14
@@ -52,14 +52,14 @@ test -b "$mddev" || exit 200 # Test alignment of PV on MD without any MD-aware or topology-aware detection # - should treat $mddev just like any other block device -pv_align="192.00k" +pv_align="1.00m" pvcreate --metadatasize 128k \ --config 'devices {md_chunk_alignment=0 data_alignment_detection=0 data_alignment_offset_detection=0}' \ $mddev check_pv_field_ $mddev pe_start $pv_align # Test md_chunk_alignment independent of topology-aware detection -pv_align="256.00k" +pv_align="1.00m" pvcreate --metadatasize 128k \ --config 'devices {data_alignment_detection=0 data_alignment_offset_detection=0}' \ $mddev
@@ -71,7 +71,8 @@ linux_minor=$(echo `uname -r` | cut -d'. # Test newer topology-aware alignment detection # - first added to 2.6.31 but not "reliable" until 2.6.33 if [ $linux_minor -ge 33 ]; then - pv_align="256.00k" + pv_align="1.00m" + # optimal_io_size=131072, minimum_io_size=65536 pvcreate --metadatasize 128k \ --config 'devices { md_chunk_alignment=0 }' $mddev check_pv_field_ $mddev pe_start $pv_align
@@ -103,15 +104,9 @@ EOF alignment_offset=`cat $sysfs_alignment_offset` || \ alignment_offset=0 - if [ "$alignment_offset" = "512" ]; then - pv_align="256.50k" - pvcreate --metadatasize 128k $mddev_p - check_pv_field_ $mddev_p pe_start $pv_align - pvremove $mddev_p - elif [ "$alignment_offset" = "2048" ]; then - pv_align="258.00k" - pvcreate --metadatasize 128k $mddev_p - check_pv_field_ $mddev_p pe_start $pv_align - pvremove $mddev_p - fi + # default alignment is 1M, add alignment_offset + pv_align=$((1048576+$alignment_offset))B + pvcreate --metadatasize 128k $mddev_p + check_pv_field_ $mddev_p pe_start $pv_align "--units b" + pvremove $mddev_p fi
test/t-pvcreate-usage.sh +3 -3
@@ -119,11 +119,11 @@ check_pv_field_ $dev1 pe_start $pv_align pvcreate --metadatasize 128k --metadatacopies 2 --dataalignment 3.5k $dev1 check_pv_field_ $dev1 pe_start $pv_align -# data area is aligned to 64k by default, +# data area is aligned to 1M by default, # data area start is shifted by the specified alignment_offset -pv_align="195.50k" +pv_align="1052160B" # 1048576 + (7*512) pvcreate --metadatasize 128k --dataalignmentoffset 7s $dev1 -check_pv_field_ $dev1 pe_start $pv_align +check_pv_field_ $dev1 pe_start $pv_align "--units b" # 2nd metadata area is created without problems when # data area start is shifted by the specified alignment_offset
test/t-topology-support.sh +1 -1
@@ -57,7 +57,7 @@ test_snapshot_mount() # FIXME add more topology-specific tests and validation (striped LVs, etc) NUM_DEVS=1 -PER_DEV_SIZE=33 +PER_DEV_SIZE=34 DEV_SIZE=$(($NUM_DEVS*$PER_DEV_SIZE)) # ---------------------------------------------
test/t-vgcreate-usage.sh +3 -3
@@ -130,11 +130,11 @@ check_pv_field_ $dev1 pe_start 200.00k vgremove -f $vg pvremove -f $dev1 -# data area is aligned to 64k by default, +# data area is aligned to 1M by default, # data area start is shifted by the specified alignment_offset -pv_align="195.50k" +pv_align="1052160B" # 1048576 + (7*512) vgcreate -c n --metadatasize 128k --dataalignmentoffset 7s $vg $dev1 -check_pv_field_ $dev1 pe_start $pv_align +check_pv_field_ $dev1 pe_start $pv_align "--units b" vgremove -f $vg pvremove -f $dev1
test/t-vgextend-usage.sh +3 -3
@@ -67,11 +67,11 @@ check_pv_field_ $dev1 pe_start 200.00k vgreduce $vg $dev1 pvremove -f $dev1 -# data area is aligned to 64k by default, +# data area is aligned to 1M by default, # data area start is shifted by the specified alignment_offset -pv_align="195.50k" +pv_align="1052160B" # 1048576 + (7*512) vgextend --metadatasize 128k --dataalignmentoffset 7s $vg $dev1 -check_pv_field_ $dev1 pe_start $pv_align +check_pv_field_ $dev1 pe_start $pv_align "--units b" vgremove -f $vg pvremove -f $dev1
test/t-vgsplit-operation.sh +1 -1
@@ -17,7 +17,7 @@ COMM() { LAST_TEST="$@" } -prepare_pvs 5 257 +prepare_pvs 5 258 # FIXME: paramaterize lvm1 vs lvm2 metadata; most of these tests should run # fine with lvm1 metadata as well; for now, just add disks 5 and 6 as lvm1 # metadata
test/test-utils.sh +1 -1
@@ -264,7 +264,7 @@ prepare_devs() { local n="$1" test -z "$n" && n=3 local devsize="$2" - test -z "$devsize" && devsize=33 + test -z "$devsize" && devsize=34 local pvname="$3" test -z "$pvname" && pvname="pv"
lib/config/defaults.h +2 -0
@@ -16,6 +16,8 @@#ifndef _LVM_DEFAULTS_H#define _LVM_DEFAULTS_H +#define DEFAULT_PE_ALIGN 2048 +#define DEFAULT_ARCHIVE_ENABLED 1#define DEFAULT_BACKUP_ENABLED 1
test/t-covercmd.sh +1 -1
@@ -30,7 +30,7 @@ pvcreate $dev1 pvcreate --metadatacopies 0 $dev2 pvcreate --metadatacopies 0 $dev3 pvcreate $dev4 -pvcreate -u $TEST_UUID --metadatacopies 0 $dev5 +pvcreate --norestorefile -u $TEST_UUID --metadatacopies 0 $dev5 vgcreate -c n $vg $devs lvcreate -n $lv -l 5 -i5 -I256 $vg
PATCH v6 2/2 change default alignment of pe_start to 1MB
[v6 adds missing --norestorefile fixes to test/t-vgcfgbackup-usage.sh]
The new standard in the storage industry is to default alignment of data areas to 1MB. fdisk, parted, and mdadm have all been updated to this default.
Update LVM to align the PV's data area start (pe_start) to 1MB. This provides a more useful default than the previous default of 64K (which generally ended up being a 192K pe_start once the first metadata area was created).
Before this patch:
# pvs -o name,vg_mda_size,pe_start PV VMdaSize 1st PE /dev/sdd 188.00k 192.00k
After this patch:
# pvs -o name,vg_mda_size,pe_start PV VMdaSize 1st PE /dev/sdd 1020.00k 1.00m
The heuristic for setting the default alignment for LVM data areas is:
- If the default value (1MB) is a multiple of the detected alignment then just use the default.
- Otherwise, use the detected value.
In practice this means we'll almost always use 1MB -- that is unless:
- the alignment was explicitly specified with --dataalignment
- or MD's full stripe width, or the {minimum,optimal}_io_size exceeds 1MB
- or the specified/detected value is not a power-of-2
--
doc/example.conf.in | 2 +- lib/config/defaults.h | 2 ++ lib/metadata/metadata.c | 33 +++++++++++++++++++++------------ test/lvm-utils.sh | 3 ++- test/t-covercmd.sh | 2 +- test/t-pvcreate-operation-md.sh | 23 +++++++++-------------- test/t-pvcreate-usage.sh | 6 +++--- test/t-topology-support.sh | 2 +- test/t-vgcfgbackup-usage.sh | 4 ++-- test/t-vgcreate-usage.sh | 6 +++--- test/t-vgextend-usage.sh | 6 +++--- test/t-vgsplit-operation.sh | 2 +- test/test-utils.sh | 2 +- 13 files changed, 50 insertions(+), 43 deletions(-)
doc/example.conf.in +1 -1
@@ -113,7 +113,7 @@ devices { # Alignment (in KB) of start of data area when creating a new PV. # If a PV is placed directly upon an md device and md_chunk_alignment or # data_alignment_detection is enabled this parameter is ignored. - # Set to 0 for the default alignment of 64KB or page size, if larger. + # Set to 0 for the default alignment of 1MB or page size, if larger. data_alignment = 0 # By default, the start of the PV's aligned data area will be shifted by
lib/metadata/metadata.c +21 -12
@@ -62,15 +62,23 @@ static uint32_t _vg_bad_status_bits(consconst char _really_init[] ="Really INITIALIZE physical volume \"%s\" of volume group \"%s\" [y/n]? " ; +static int _alignment_overrides_default (unsigned long data_alignment) +{ +return data_alignment && (DEFAULT_PE_ALIGN % data_alignment); +} +unsigned long set_pe_align (struct physical_volume *pv,unsigned long data_alignment) { +unsigned long temp_pe_align; +if (pv->pe_align) goto out;if (data_alignment) pv->pe_align = data_alignment;else - pv->pe_align =MAX (65536UL ,lvm_getpagesize ()) >>SECTOR_SHIFT ; + pv->pe_align =MAX ((DEFAULT_PE_ALIGN <<SECTOR_SHIFT ), +lvm_getpagesize ()) >>SECTOR_SHIFT ;if (!pv->dev) goto out;
@@ -79,10 +87,11 @@ unsigned long set_pe_align(struct physic* Align to stripe-width of underlying md device if present */ if (find_config_tree_bool (pv->fmt->cmd,"devices/md_chunk_alignment" , -DEFAULT_MD_CHUNK_ALIGNMENT )) - pv->pe_align =MAX (pv->pe_align, -dev_md_stripe_width (pv->fmt->cmd->sysfs_dir, - pv->dev)); +DEFAULT_MD_CHUNK_ALIGNMENT )) { + temp_pe_align =dev_md_stripe_width (pv->fmt->cmd->sysfs_dir, pv->dev); +if (_alignment_overrides_default (temp_pe_align)) + pv->pe_align = temp_pe_align; + }/* * Align to topology's minimum_io_size or optimal_io_size if present
@@ -94,13 +103,13 @@ unsigned long set_pe_align(struct physicif (find_config_tree_bool (pv->fmt->cmd,"devices/data_alignment_detection" ,DEFAULT_DATA_ALIGNMENT_DETECTION )) { - pv->pe_align =MAX (pv->pe_align, -dev_minimum_io_size (pv->fmt->cmd->sysfs_dir, - pv->dev)); - - pv->pe_align =MAX (pv->pe_align, -dev_optimal_io_size (pv->fmt->cmd->sysfs_dir, - pv->dev)); + temp_pe_align =dev_minimum_io_size (pv->fmt->cmd->sysfs_dir, pv->dev); +if (_alignment_overrides_default (temp_pe_align)) + pv->pe_align = temp_pe_align; + + temp_pe_align =dev_optimal_io_size (pv->fmt->cmd->sysfs_dir, pv->dev); +if (_alignment_overrides_default (temp_pe_align)) + pv->pe_align = temp_pe_align; } log_very_verbose("%s: Setting PE alignment to %lu sectors.",
test/lvm-utils.sh +2 -1
@@ -103,9 +103,10 @@ check_pv_field_() local pv=$1; local field=$2; local expected=$3; + local pvs_args=$4; # optional local actual; - actual=$(trim $(pvs --noheadings -o $field $pv)) + actual=$(trim $(pvs --noheadings $pvs_args -o $field $pv)) if test "$verbose" = "t" then echo "check_pv_field_ PV=$pv, field=$field, actual=$actual, expected=$expected"
test/t-pvcreate-operation-md.sh +9 -14
@@ -52,14 +52,14 @@ test -b "$mddev" || exit 200 # Test alignment of PV on MD without any MD-aware or topology-aware detection # - should treat $mddev just like any other block device -pv_align="192.00k" +pv_align="1.00m" pvcreate --metadatasize 128k \ --config 'devices {md_chunk_alignment=0 data_alignment_detection=0 data_alignment_offset_detection=0}' \ $mddev check_pv_field_ $mddev pe_start $pv_align # Test md_chunk_alignment independent of topology-aware detection -pv_align="256.00k" +pv_align="1.00m" pvcreate --metadatasize 128k \ --config 'devices {data_alignment_detection=0 data_alignment_offset_detection=0}' \ $mddev
@@ -71,7 +71,8 @@ linux_minor=$(echo `uname -r` | cut -d'. # Test newer topology-aware alignment detection # - first added to 2.6.31 but not "reliable" until 2.6.33 if [ $linux_minor -ge 33 ]; then - pv_align="256.00k" + pv_align="1.00m" + # optimal_io_size=131072, minimum_io_size=65536 pvcreate --metadatasize 128k \ --config 'devices { md_chunk_alignment=0 }' $mddev check_pv_field_ $mddev pe_start $pv_align
@@ -103,15 +104,9 @@ EOF alignment_offset=`cat $sysfs_alignment_offset` || \ alignment_offset=0 - if [ "$alignment_offset" = "512" ]; then - pv_align="256.50k" - pvcreate --metadatasize 128k $mddev_p - check_pv_field_ $mddev_p pe_start $pv_align - pvremove $mddev_p - elif [ "$alignment_offset" = "2048" ]; then - pv_align="258.00k" - pvcreate --metadatasize 128k $mddev_p - check_pv_field_ $mddev_p pe_start $pv_align - pvremove $mddev_p - fi + # default alignment is 1M, add alignment_offset + pv_align=$((1048576+$alignment_offset))B + pvcreate --metadatasize 128k $mddev_p + check_pv_field_ $mddev_p pe_start $pv_align "--units b" + pvremove $mddev_p fi
test/t-pvcreate-usage.sh +3 -3
@@ -119,11 +119,11 @@ check_pv_field_ $dev1 pe_start $pv_align pvcreate --metadatasize 128k --metadatacopies 2 --dataalignment 3.5k $dev1 check_pv_field_ $dev1 pe_start $pv_align -# data area is aligned to 64k by default, +# data area is aligned to 1M by default, # data area start is shifted by the specified alignment_offset -pv_align="195.50k" +pv_align="1052160B" # 1048576 + (7*512) pvcreate --metadatasize 128k --dataalignmentoffset 7s $dev1 -check_pv_field_ $dev1 pe_start $pv_align +check_pv_field_ $dev1 pe_start $pv_align "--units b" # 2nd metadata area is created without problems when # data area start is shifted by the specified alignment_offset
test/t-topology-support.sh +1 -1
@@ -57,7 +57,7 @@ test_snapshot_mount() # FIXME add more topology-specific tests and validation (striped LVs, etc) NUM_DEVS=1 -PER_DEV_SIZE=33 +PER_DEV_SIZE=34 DEV_SIZE=$(($NUM_DEVS*$PER_DEV_SIZE)) # ---------------------------------------------
test/t-vgcreate-usage.sh +3 -3
@@ -130,11 +130,11 @@ check_pv_field_ $dev1 pe_start 200.00k vgremove -f $vg pvremove -f $dev1 -# data area is aligned to 64k by default, +# data area is aligned to 1M by default, # data area start is shifted by the specified alignment_offset -pv_align="195.50k" +pv_align="1052160B" # 1048576 + (7*512) vgcreate -c n --metadatasize 128k --dataalignmentoffset 7s $vg $dev1 -check_pv_field_ $dev1 pe_start $pv_align +check_pv_field_ $dev1 pe_start $pv_align "--units b" vgremove -f $vg pvremove -f $dev1
test/t-vgextend-usage.sh +3 -3
@@ -67,11 +67,11 @@ check_pv_field_ $dev1 pe_start 200.00k vgreduce $vg $dev1 pvremove -f $dev1 -# data area is aligned to 64k by default, +# data area is aligned to 1M by default, # data area start is shifted by the specified alignment_offset -pv_align="195.50k" +pv_align="1052160B" # 1048576 + (7*512) vgextend --metadatasize 128k --dataalignmentoffset 7s $vg $dev1 -check_pv_field_ $dev1 pe_start $pv_align +check_pv_field_ $dev1 pe_start $pv_align "--units b" vgremove -f $vg pvremove -f $dev1
test/t-vgsplit-operation.sh +1 -1
@@ -17,7 +17,7 @@ COMM() { LAST_TEST="$@" } -prepare_pvs 5 257 +prepare_pvs 5 258 # FIXME: paramaterize lvm1 vs lvm2 metadata; most of these tests should run # fine with lvm1 metadata as well; for now, just add disks 5 and 6 as lvm1 # metadata
test/test-utils.sh +1 -1
@@ -264,7 +264,7 @@ prepare_devs() { local n="$1" test -z "$n" && n=3 local devsize="$2" - test -z "$devsize" && devsize=33 + test -z "$devsize" && devsize=34 local pvname="$3" test -z "$pvname" && pvname="pv"
lib/config/defaults.h +2 -0
@@ -16,6 +16,8 @@#ifndef _LVM_DEFAULTS_H#define _LVM_DEFAULTS_H +#define DEFAULT_PE_ALIGN 2048 +#define DEFAULT_ARCHIVE_ENABLED 1#define DEFAULT_BACKUP_ENABLED 1
test/t-covercmd.sh +1 -1
@@ -30,7 +30,7 @@ pvcreate $dev1 pvcreate --metadatacopies 0 $dev2 pvcreate --metadatacopies 0 $dev3 pvcreate $dev4 -pvcreate -u $TEST_UUID --metadatacopies 0 $dev5 +pvcreate --norestorefile -u $TEST_UUID --metadatacopies 0 $dev5 vgcreate -c n $vg $devs lvcreate -n $lv -l 5 -i5 -I256 $vg
test/t-vgcfgbackup-usage.sh +2 -2
@@ -37,6 +37,6 @@ pvcreate -ff -y $dev1 pvcreate -ff -y $dev2 vgcfgbackup -f "$(pwd)/backup.$$" $vg sed 's/flags = \[\"MISSING\"\]/flags = \[\]/' "$(pwd)/backup.$$" > "$(pwd)/backup.$$1" -pvcreate -ff -y -u $pv1_uuid $dev1 -pvcreate -ff -y -u $pv2_uuid $dev2 +pvcreate -ff -y --norestorefile -u $pv1_uuid $dev1 +pvcreate -ff -y --norestorefile -u $pv2_uuid $dev2 vgcfgrestore -f "$(pwd)/backup.$$1" $vg
[PATCH 3/2] document --norestorefile in pvcreate man page
In reply to Mike Snitzerdocument --norestorefile in pvcreate man page
--- man/pvcreate.8.in | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
man/pvcreate.8.in +8 -1
@@ -17,6 +17,7 @@ pvcreate \- initialize a disk or partiti .RB [ \-\-dataalignment alignment ] .RB [ \-\-dataalignmentoffset alignment_offset ] .RB [ \-\-restorefile file ] +.RB [ \-\-norestorefile ] .RB [ \-\-setphysicalvolumesize size ] .RB [ \-u | \-\-uuid uuid ] .RB [ \-\-version ]
@@ -60,7 +61,9 @@ Specify the uuid for the device. Without this option, \fBpvcreate\fP generates a random uuid. All of your physical volumes must have unique uuids. You need to use this option before restoring a backup of LVM metadata -onto a replacement device - see \fBvgcfgrestore\fP(8). +onto a replacement device - see \fBvgcfgrestore\fP(8). As such, use of +\fB--restorefile\fP is compulsory unless the \fB--norestorefile\fP is +used. .TP .BR \-y ", " \-\-yes Answer yes to all questions.
@@ -138,6 +141,10 @@ the same place and not get overwritten b a mechanism to upgrade the metadata format or to add/remove metadata areas. Use with care. See also \fBvgconvert\fP(8). .TP +.BR \-\-norestorefile +In conjunction with \fB--uuid\fP, this allows a uuid to be specified +without also requiring that a backup of the metadata be provided. +.TP .BR \-\-labelsector " sector" By default the PV is labelled with an LVM2 identifier in its second sector (sector 1). This lets you use a different sector near the