1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-03 05:18:29 +03:00

Second path on "pvcreate -s"

This commit is contained in:
Heinz Mauelshagen 2002-02-15 14:33:59 +00:00
parent 052360e901
commit e1d93eb457
5 changed files with 21 additions and 10 deletions

View File

@ -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, static int _pv_setup(struct format_instance *fi, struct physical_volume *pv,
struct volume_group *vg) 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) { if (pv->size > MAX_PV_SIZE) {
log_error("physical volumes cannot be bigger than 2TB"); log_error("physical volumes cannot be bigger than 2TB");
return 0; return 0;
} }
/* setup operations which need members derived from the VG */
if (!vg) return 1;
/* /*
* This works out pe_start and pe_count. * This works out pe_start and pe_count.
*/ */

View File

@ -45,14 +45,6 @@ int _add_pv_to_vg(struct format_instance *fi, struct volume_group *vg,
return 0; return 0;
} }
/* Units of 512-byte sectors */
/*
if (!dev_get_size(pv->dev, &pv->size)) {
stack;
return 0;
}
*/
/* Units of 512-byte sectors */ /* Units of 512-byte sectors */
pv->pe_size = vg->extent_size; 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_start = 0;
pv->pe_count = 0; pv->pe_count = 0;
pv->pe_allocated = 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; return pv;
bad: bad:

View File

@ -259,6 +259,7 @@ int size_arg(struct arg *a)
v *= 1024; v *= 1024;
} }
a->i_value = (uint32_t) v; a->i_value = (uint32_t) v;
a->i64_value = (uint64_t) v;
return 1; return 1;

View File

@ -92,7 +92,7 @@ static void pvcreate_single(struct cmd_context *cmd, const char *pv_name)
if (!pvcreate_check(cmd, pv_name)) if (!pvcreate_check(cmd, pv_name))
return; 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))) { if (!(pv = pv_create(cmd->fid, pv_name, idp, size))) {
log_err("Failed to setup physical volume \"%s\"", pv_name); log_err("Failed to setup physical volume \"%s\"", pv_name);
return; return;

View File

@ -73,6 +73,7 @@ struct arg {
int count; int count;
char *value; char *value;
uint32_t i_value; uint32_t i_value;
uint64_t i64_value;
sign_t sign; 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; 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) 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; return arg_count(cmd, a) ? cmd->args[a].sign : def;