From e1d93eb457951228711aaee9527203763d4e8360 Mon Sep 17 00:00:00 2001 From: Heinz Mauelshagen Date: Fri, 15 Feb 2002 14:33:59 +0000 Subject: [PATCH] Second path on "pvcreate -s" --- lib/format1/format1.c | 7 ++++++- lib/metadata/metadata.c | 14 ++++++-------- tools/lvm.c | 1 + tools/pvcreate.c | 2 +- tools/tools.h | 7 +++++++ 5 files changed, 21 insertions(+), 10 deletions(-) diff --git a/lib/format1/format1.c b/lib/format1/format1.c index 27080aedd..39c021f4e 100644 --- a/lib/format1/format1.c +++ b/lib/format1/format1.c @@ -394,12 +394,17 @@ static struct list *_get_vgs(struct format_instance *fi) static int _pv_setup(struct format_instance *fi, struct physical_volume *pv, struct volume_group *vg) { - if (pv->size == MAX_PV_SIZE) pv->size--; + /* setup operations for the PV structure */ + + if (pv->size > MAX_PV_SIZE) pv->size--; if (pv->size > MAX_PV_SIZE) { log_error("physical volumes cannot be bigger than 2TB"); return 0; } + /* setup operations which need members derived from the VG */ + if (!vg) return 1; + /* * This works out pe_start and pe_count. */ diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c index fd91509c7..12a39ec94 100644 --- a/lib/metadata/metadata.c +++ b/lib/metadata/metadata.c @@ -45,14 +45,6 @@ int _add_pv_to_vg(struct format_instance *fi, struct volume_group *vg, return 0; } - /* Units of 512-byte sectors */ -/* - if (!dev_get_size(pv->dev, &pv->size)) { - stack; - return 0; - } -*/ - /* Units of 512-byte sectors */ pv->pe_size = vg->extent_size; @@ -238,6 +230,12 @@ struct physical_volume *pv_create(struct format_instance *fi, pv->pe_start = 0; pv->pe_count = 0; pv->pe_allocated = 0; + + if (!fi->ops->pv_setup(fi, pv, NULL)) { + log_error("Format-specific setup of physical volume '%s' " + "failed.", name); + goto bad; + } return pv; bad: diff --git a/tools/lvm.c b/tools/lvm.c index 6542ba2e6..182d9e13d 100644 --- a/tools/lvm.c +++ b/tools/lvm.c @@ -259,6 +259,7 @@ int size_arg(struct arg *a) v *= 1024; } a->i_value = (uint32_t) v; + a->i64_value = (uint64_t) v; return 1; diff --git a/tools/pvcreate.c b/tools/pvcreate.c index 77137054e..41595930c 100644 --- a/tools/pvcreate.c +++ b/tools/pvcreate.c @@ -92,7 +92,7 @@ static void pvcreate_single(struct cmd_context *cmd, const char *pv_name) if (!pvcreate_check(cmd, pv_name)) return; - size = arg_int_value(cmd, physicalvolumesize_ARG, 0) * 2; + size = arg_int64_value(cmd, physicalvolumesize_ARG, 0) * 2; if (!(pv = pv_create(cmd->fid, pv_name, idp, size))) { log_err("Failed to setup physical volume \"%s\"", pv_name); return; diff --git a/tools/tools.h b/tools/tools.h index 6677a2da6..34dfdb5a6 100644 --- a/tools/tools.h +++ b/tools/tools.h @@ -73,6 +73,7 @@ struct arg { int count; char *value; uint32_t i_value; + uint64_t i64_value; sign_t sign; }; @@ -122,6 +123,12 @@ static inline uint32_t arg_int_value(struct cmd_context *cmd, int a, return arg_count(cmd, a) ? cmd->args[a].i_value : def; } +static inline uint64_t arg_int64_value(struct cmd_context *cmd, int a, + uint64_t def) +{ + return arg_count(cmd, a) ? cmd->args[a].i64_value : def; +} + static inline sign_t arg_sign_value(struct cmd_context *cmd, int a, sign_t def) { return arg_count(cmd, a) ? cmd->args[a].sign : def;