1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-30 17:18:21 +03:00

systemid: Init and merge lvm2 and lvm1 fields.

Use system_id field in preference to lvm1_system_id.
Initialise both for now.
This commit is contained in:
Alasdair G Kergon 2015-03-04 01:00:51 +00:00
parent dcba4781ea
commit 3562b5ab39
8 changed files with 19 additions and 8 deletions

View File

@ -695,7 +695,7 @@ void vgdisplay_full(const struct volume_group *vg)
log_print("--- Volume group ---");
log_print("VG Name %s", vg->name);
log_print("System ID %s", vg->system_id);
log_print("System ID %s", (vg->system_id && *vg->system_id) ? vg->system_id : vg->lvm1_system_id ? : "");
log_print("Format %s", vg->fid->fmt->name);
if (vg->fid->fmt->features & FMT_MDAS) {
log_print("Metadata Areas %d",

View File

@ -156,8 +156,10 @@ int export_pv(struct cmd_context *cmd, struct dm_pool *mem __attribute__((unused
}
/* Preserve existing system_id if it exists */
if (vg && *vg->lvm1_system_id)
if (vg && vg->lvm1_system_id && *vg->lvm1_system_id)
strncpy((char *)pvd->system_id, vg->lvm1_system_id, sizeof(pvd->system_id));
else if (vg && vg->system_id && *vg->system_id)
strncpy((char *)pvd->system_id, vg->system_id, sizeof(pvd->system_id));
/* Is VG already exported or being exported? */
if (vg && vg_is_exported(vg)) {

View File

@ -417,6 +417,8 @@ static int _print_vg(struct formatter *f, struct volume_group *vg)
if (vg->system_id && *vg->system_id)
outf(f, "system_id = \"%s\"", vg->system_id);
else if (vg->lvm1_system_id && *vg->lvm1_system_id)
outf(f, "system_id = \"%s\"", vg->lvm1_system_id);
outsize(f, (uint64_t) vg->extent_size, "extent_size = %u",
vg->extent_size);

View File

@ -883,8 +883,6 @@ static struct volume_group *_read_vg(struct format_instance *fid,
dm_hash_destroy(pv_hash);
dm_hash_destroy(lv_hash);
/* FIXME Determine format type from file contents */
/* eg Set to instance of fmt1 here if reading a format1 backup? */
vg_set_fid(vg, fid);
/*

View File

@ -47,6 +47,8 @@ struct volume_group *alloc_vg(const char *pool_name, struct cmd_context *cmd,
return NULL;
}
vg->system_id = "";
vg->cmd = cmd;
vg->vgmem = vgmem;
vg->alloc = ALLOC_NORMAL;
@ -627,6 +629,9 @@ int vg_set_system_id(struct volume_group *vg, const char *system_id)
return 0;
}
if (vg->lvm1_system_id)
*vg->lvm1_system_id = '\0';
return 1;
}

View File

@ -989,7 +989,7 @@ static int _vgsystemid_disp(struct dm_report *rh, struct dm_pool *mem,
const void *data, void *private)
{
const struct volume_group *vg = (const struct volume_group *) data;
const char *repstr = vg->system_id ? : vg->lvm1_system_id ? : "";
const char *repstr = (vg->system_id && *vg->system_id) ? vg->system_id : vg->lvm1_system_id ? : "";
return _string_disp(rh, mem, field, &repstr, private);
}

View File

@ -200,8 +200,9 @@ static int _ignore_vg(struct volume_group *vg, const char *vg_name,
*/
if (read_error & FAILED_SYSTEMID) {
if (arg_vgnames && str_list_match_item(arg_vgnames, vg->name)) {
log_error("Cannot access VG %s with system ID %s with local system ID %s.",
vg->name, vg->system_id, vg->cmd->system_id);
log_error("Cannot access VG %s with system ID %s with %slocal system ID%s%s.",
vg->name, vg->system_id, vg->cmd->system_id ? "" : "unknown ",
vg->cmd->system_id ? " " : "", vg->cmd->system_id ? vg->cmd->system_id : "");
return 1;
} else {
read_error &= ~FAILED_SYSTEMID; /* Check for other errors */

View File

@ -576,6 +576,9 @@ static int _vgchange_system_id(struct cmd_context *cmd, struct volume_group *vg)
vg->system_id = system_id;
if (vg->lvm1_system_id)
*vg->lvm1_system_id = '\0';
return 1;
}