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

Fix vgmerge to handle duplicate LVIDs.

This commit is contained in:
Alasdair Kergon 2005-05-19 16:48:51 +00:00
parent d910e40de6
commit 21ca3b1227
3 changed files with 29 additions and 4 deletions

View File

@ -1,5 +1,6 @@
Version 2.01.11 -
==============================
Fix vgmerge to handle duplicate LVIDs.
Move archiver code from tools into library.
vgscan/change/display/vgs automatically create metadata backups if needed.
Merge cloned allocation functions.

View File

@ -626,14 +626,11 @@ struct lv_list *find_lv_in_vg(struct volume_group *vg, const char *lv_name)
struct lv_list *find_lv_in_vg_by_lvid(struct volume_group *vg,
const union lvid *lvid)
{
struct list *lvh;
struct lv_list *lvl;
list_iterate(lvh, &vg->lvs) {
lvl = list_item(lvh, struct lv_list);
list_iterate_items(lvl, &vg->lvs)
if (!strncmp(lvl->lv->lvid.s, lvid->s, sizeof(*lvid)))
return lvl;
}
return NULL;
}

View File

@ -140,6 +140,33 @@ static int _vgmerge_single(struct cmd_context *cmd, const char *vg_name_to,
}
vg_to->pv_count += vg_from->pv_count;
/* Fix up LVIDs */
list_iterate_items(lvl1, &vg_to->lvs) {
union lvid *lvid1 = &lvl1->lv->lvid;
char uuid[64];
list_iterate_items(lvl2, &vg_from->lvs) {
union lvid *lvid2 = &lvl2->lv->lvid;
if (id_equal(&lvid1->id[1], &lvid2->id[1])) {
if (!id_create(&lvid2->id[1])) {
log_error("Failed to generate new "
"random LVID for %s",
lvl2->lv->name);
goto error;
}
if (!id_write_format(&lvid2->id[1], uuid,
sizeof(uuid))) {
stack;
goto error;
}
log_verbose("Changed LVID for %s to %s",
lvl2->lv->name, uuid);
}
}
}
while (!list_empty(&vg_from->lvs)) {
struct list *lvh = vg_from->lvs.n;