1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-18 10:04:20 +03:00

Allocate fixed space for vg->system_id when vg is created, instead of

dynamically.
This commit is contained in:
Alasdair Kergon 2002-01-30 12:47:29 +00:00
parent 93d6fa7d0d
commit 851866d2fc
2 changed files with 19 additions and 17 deletions

View File

@ -50,14 +50,11 @@ int import_pv(struct pool *mem, struct device *dev,
return 0;
}
/* Store system_id if PV belongs to a VG */
if (vg && !vg->system_id &&
!(vg->system_id = pool_strdup(mem, pvd->system_id))) {
stack;
return 0;
}
/* Store system_id from first PV if PV belongs to a VG */
if (vg && !*vg->system_id)
strncpy(vg->system_id, pvd->system_id, NAME_LEN);
if (vg && vg->system_id &&
if (vg &&
strncmp(vg->system_id, pvd->system_id, sizeof(pvd->system_id)))
log_very_verbose("System ID %s on %s differs from %s for "
"volume group", pvd->system_id,
@ -122,13 +119,13 @@ int export_pv(struct pool *mem, struct volume_group *vg,
strncpy(pvd->vg_name, pv->vg_name, sizeof(pvd->vg_name));
/* Preserve existing system_id if it exists */
if (vg && vg->system_id)
if (vg && *vg->system_id)
strncpy(pvd->system_id, vg->system_id, sizeof(pvd->system_id));
/* Is VG already exported or being exported? */
if (vg && (vg->status & EXPORTED_VG)) {
/* Does system_id need setting? */
if (!vg->system_id ||
if (!*vg->system_id ||
strncmp(vg->system_id, EXPORTED_TAG,
sizeof(EXPORTED_TAG) - 1)) {
if (!_system_id(pvd->system_id, EXPORTED_TAG)) {
@ -146,7 +143,7 @@ int export_pv(struct pool *mem, struct volume_group *vg,
}
/* Is VG being imported? */
if (vg && !(vg->status & EXPORTED_VG) && vg->system_id &&
if (vg && !(vg->status & EXPORTED_VG) && *vg->system_id &&
!strncmp(vg->system_id, EXPORTED_TAG, sizeof(EXPORTED_TAG) - 1)) {
if (!_system_id(pvd->system_id, IMPORTED_TAG)) {
stack;
@ -163,12 +160,9 @@ int export_pv(struct pool *mem, struct volume_group *vg,
/* Update internal system_id if we changed it */
if (vg &&
(!vg->system_id ||
strncmp(vg->system_id, pvd->system_id,
sizeof(pvd->system_id)))) {
if (!(vg->system_id = pool_strdup(mem, pvd->system_id)))
log_error("System ID update failed");
}
(!*vg->system_id ||
strncmp(vg->system_id, pvd->system_id, sizeof(pvd->system_id))))
strncpy(vg->system_id, pvd->system_id, NAME_LEN);
//pvd->pv_major = MAJOR(pv->dev);
@ -202,6 +196,13 @@ int import_vg(struct pool *mem,
return 0;
}
if (!(vg->system_id = pool_alloc(mem, NAME_LEN))) {
stack;
return 0;
}
*vg->system_id = '\0';
if (vgd->vg_status & VG_EXPORTED)
vg->status |= EXPORTED_VG;

View File

@ -153,7 +153,8 @@ struct volume_group *vg_create(struct format_instance *fi, const char *vg_name,
}
vg->status = (RESIZEABLE_VG | LVM_READ | LVM_WRITE);
vg->system_id = NULL;
vg->system_id = pool_alloc(mem, NAME_LEN);
*vg->system_id = '\0';
vg->extent_size = extent_size;
vg->extent_count = 0;