Skip to contentSkip to conversation

master - pv_header_extension: add support for writing PV header extension (flags & Embedding Area)

PATCH Peter Rajnoha 1 participant 1 message Feb 26, 2013

lore
Share & tools
lore
#0 lore raw
Gitweb:        http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=b778653f03702a967df11d51d842abb9a9b86068
Commit:        b778653f03702a967df11d51d842abb9a9b86068
Parent:        9dbe25709e3805fbbc8024f0be68de2aae815747
Author:        Peter Rajnoha <[email protected]>
AuthorDate:    Fri Feb 15 11:02:53 2013 +0100
Committer:     Peter Rajnoha <[email protected]>
CommitterDate: Tue Feb 26 11:28:00 2013 +0100

pv_header_extension: add support for writing PV header extension (flags & Embedding Area)

The PV header extension information (PV header extension version, flags and list of Embedding Area locations) is stored just beyond the PV header base.

When calculating the Embedding Area start value (ea_start), the same logic is used as when calculating the pe_start value for Data Area - the value must follow exactly the same alignment restrictions for its start value (the alignment detected automatically or provided via command line using the --dataalignment and --dataalignmentoffset arguments).

The Embedding Area is placed at the very start of the PV, starting at ea_start. The Data Area starting at pe_start is placed next. The pe_start is still properly aligned. Due to the pe_start alignment, it's possible that the resulting Embedding Area size (ea_size) ends up bigger in size than requested (but never less than requested).

---
 lib/format1/format1.c            |    2 +
 lib/format_text/export.c         |    5 ++
 lib/format_text/format-text.c    |  108 ++++++++++++++++++++++++++++++-------
 lib/format_text/text_label.c     |   73 ++++++++++++++++++-------
 lib/metadata/metadata-exported.h |    2 +
 lib/metadata/metadata.c          |    2 +
 tools/pvcreate.c                 |    2 +
 7 files changed, 153 insertions(+), 41 deletions(-)
lib/format1/format1.c +2 -0
index c90c266..f3945bc 100644
@@ -379,6 +379,8 @@ static int _format1_pv_setup(const struct format_type *fmt,
 	struct pvcreate_restorable_params rp = {.restorefile = NULL,
 						.id = {{0}},
 						.idp = NULL,
+						.ea_start = 0,
+						.ea_size = 0,
 						.pe_start = 0,
 						.extent_count = 0,
 						.extent_size = vg->extent_size};
lib/format_text/export.c +5 -0
index d68daf5..6d83106 100644
@@ -490,6 +490,11 @@ static int _print_pvs(struct formatter *f, struct volume_group *vg)
 		outsize(f, vg->extent_size * (uint64_t) pv->pe_count,
 			"pe_count = %u", pv->pe_count);
 
+		if (pv->ea_start && pv->ea_size) {
+			outf(f, "ea_start = %" PRIu64, pv->ea_start);
+			outsize(f, pv->ea_size, "ea_size = %" PRIu64, pv->ea_size);
+		}
+
 		_dec_indent(f);
 		outf(f, "}");
 	}
lib/format_text/format-text.c +87 -21

161 lines not on this page · raw message

lib/format_text/text_label.c +53 -20

128 lines not on this page · raw message

lib/metadata/metadata-exported.h +2 -0
index 6624a40..0ce5ad5 100644
@@ -398,6 +398,8 @@ struct pvcreate_restorable_params {
 	const char *restorefile; /* 0 if no --restorefile option */
 	struct id id; /* FIXME: redundant */
 	struct id *idp; /* 0 if no --uuid option */
+	uint64_t ea_start;
+	uint64_t ea_size;
 	uint64_t pe_start;
 	uint32_t extent_count;
 	uint32_t extent_size;
lib/metadata/metadata.c +2 -0
index 2c071b0..0996184 100644
@@ -1430,6 +1430,8 @@ void pvcreate_params_set_defaults(struct pvcreate_params *pp)
 	pp->metadataignore = DEFAULT_PVMETADATAIGNORE;
 	pp->rp.restorefile = 0;
 	pp->rp.idp = 0;
+	pp->rp.ea_start = 0;
+	pp->rp.ea_size = 0;
 	pp->rp.pe_start = PV_PE_START_CALC;
 	pp->rp.extent_count = 0;
 	pp->rp.extent_size = 0;
tools/pvcreate.c +2 -0
index eb2fb5e..5b83a18 100644
@@ -73,6 +73,8 @@ static int pvcreate_restore_params_validate(struct cmd_context *cmd,
 				  uuid, pp->rp.restorefile);
 			return 0;
 		}
+		pp->rp.ea_start = pv_ea_start(existing_pvl->pv);
+		pp->rp.ea_size = pv_ea_size(existing_pvl->pv);
 		pp->rp.pe_start = pv_pe_start(existing_pvl->pv);
 		pp->rp.extent_size = pv_pe_size(existing_pvl->pv);
 		pp->rp.extent_count = pv_pe_count(existing_pvl->pv);