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

lvmetad: Avoid duplicate entries in the list of alternate devices.

This commit is contained in:
Petr Rockai 2015-04-23 01:39:39 +02:00 committed by Petr Rockai
parent 3be3eb2995
commit 4946c64092

View File

@ -936,12 +936,29 @@ static response pv_found(lvmetad_state *s, request r)
altdev = dm_config_clone_node(cft, altdev, 0); altdev = dm_config_clone_node(cft, altdev, 0);
chain_node(altdev, cft->root, 0); chain_node(altdev, cft->root, 0);
} else } else
altdev = make_config_node(cft, "devices_alternate", cft->root, 0); if (!(altdev = make_config_node(cft, "devices_alternate", cft->root, 0)))
if (!altdev || !(altdev_v = dm_config_create_value(cft))) goto out_of_mem;
goto out_of_mem; altdev_v = altdev->v;
altdev_v->next = altdev->v; while (1) {
altdev->v = altdev_v; if (altdev_v && altdev_v->v.i == device_old_pvid)
altdev->v->v.i = device_old_pvid; break;
if (altdev_v)
altdev_v = altdev_v->next;
if (!altdev_v) {
if (!(altdev_v = dm_config_create_value(cft)))
goto out_of_mem;
altdev_v->next = altdev->v;
altdev->v = altdev_v;
altdev->v->v.i = device_old_pvid;
break;
}
};
altdev_v = altdev->v;
while (altdev_v) {
if (altdev_v->next && altdev_v->next->v.i == device)
altdev_v->next = altdev_v->next->next;
altdev_v = altdev_v->next;
}
changed |= 1; changed |= 1;
} }