Only write metadata_copies to if explicitly set or read
cover Only write metadata_copies to if explicitly set or read
This patch only writes the new "metadata_copies" field in the vg metadata if a new value is explicitly set, or the value was already in the vg metadata.
Personally, I don't think this patch is necessary, given the fact that previous versions of LVM don't parse fields they doesn't understand. However I can add this patch to the previous metadata balance patch set if others feel it is a requirement.
PATCH 1/1 Only write metadata_copies to vg metadata if read or non-zero.
If already present on disk, or the user sets the value, enable writing the value out to disk. Otherwise, skip committing metadata_copies to the vg metadata.
Signed-off-by Dave Wysochanski <[email protected]>
--- lib/format_text/export.c | 6 +++++- lib/format_text/import_vsn1.c | 2 ++ lib/metadata/metadata-exported.h | 1 + lib/metadata/metadata.c | 1 + 4 files changed, 9 insertions(+), 1 deletions(-)
lib/format_text/export.c +5 -1
@@ -397,7 +397,11 @@ static int _print_vg(struct formatter *f, struct volume_group *vg)outf (f,"allocation_policy = \"%s\"" ,get_alloc_string (vg->alloc)); } -outf (f,"metadata_copies = %u" , vg->mda_copies); +/* +* Only write to the metadata if the value is valid or non-zero. +*/ +if (vg->mda_copies_valid || vg->mda_copies) +outf (f,"metadata_copies = %u" , vg->mda_copies);return 1 ; }
lib/format_text/import_vsn1.c +2 -0
@@ -746,7 +746,9 @@ static struct volume_group *_read_vg(struct format_instance *fid, return_0; } + vg->mda_copies_valid =1 ;if (!_read_uint32 (vgn,"metadata_copies" , &vg->mda_copies)) { + vg->mda_copies_valid =0 ; vg->mda_copies =DEFAULT_VGMETADATACOPIES ; }
lib/metadata/metadata-exported.h +1 -0
@@ -282,6 +282,7 @@ struct volume_group {*/ uint32_t read_status;uint32_t mda_copies;/* target number of mdas for this VG */ +uint32_t mda_copies_valid;/* 1 if user enables feature */ };/* There will be one area for each stripe */
lib/metadata/metadata.c +1 -0
@@ -1105,6 +1105,7 @@ int vg_set_mda_copies(struct volume_group *vg, uint32_t value)* enable some mdas on PVS */ vg->mda_copies = value; + vg->mda_copies_valid =1 ;return 1 ; }
Signature · 1 line
1.6.0.6