From 7042e06a2aa4b93b9e942996b78b2dd52e3cabe7 Mon Sep 17 00:00:00 2001 From: Dave Wysochanski Date: Mon, 28 Jun 2010 20:37:10 +0000 Subject: [PATCH] Make vg->mda_copies persistent in on disk vg metadata. This patch adds the ability to read/write the vg->mda_copies values from/to the vg metadata. If we read the VG metadata and this field does not exist, we set mda_copies to the default value of 0. Later in the code, we use this special '0' value to indicate a disable of metadata balancing. This should preserve existing LVM behavior and ensure metadata balancing can be turned off should the need arise. Signed-off-by: Dave Wysochanski --- lib/format_text/export.c | 1 + lib/format_text/import_vsn1.c | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/lib/format_text/export.c b/lib/format_text/export.c index 5f02b5d61..52ae11c22 100644 --- a/lib/format_text/export.c +++ b/lib/format_text/export.c @@ -397,6 +397,7 @@ 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); return 1; } diff --git a/lib/format_text/import_vsn1.c b/lib/format_text/import_vsn1.c index 316adb555..62bcbec18 100644 --- a/lib/format_text/import_vsn1.c +++ b/lib/format_text/import_vsn1.c @@ -23,6 +23,7 @@ #include "pv_alloc.h" #include "segtype.h" #include "text_import.h" +#include "defaults.h" typedef int (*section_fn) (struct format_instance * fid, struct dm_pool * mem, struct volume_group * vg, struct config_node * pvn, @@ -745,6 +746,10 @@ static struct volume_group *_read_vg(struct format_instance *fid, return_0; } + if (!_read_uint32(vgn, "metadata_copies", &vg->mda_copies)) { + vg->mda_copies = DEFAULT_VGMETADATACOPIES; + } + /* * The pv hash memorises the pv section names -> pv * structures.