From 0d03503a453f91cee09fb3a1664d2136d58ac751 Mon Sep 17 00:00:00 2001 From: Petr Rockai Date: Fri, 4 Oct 2013 14:30:00 +0200 Subject: [PATCH] lvmetad: Fix vgname->vgid hash updates w/ duplicate VG names. --- daemons/lvmetad/lvmetad-core.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/daemons/lvmetad/lvmetad-core.c b/daemons/lvmetad/lvmetad-core.c index 4f7bf59ed..e1ec5a848 100644 --- a/daemons/lvmetad/lvmetad-core.c +++ b/daemons/lvmetad/lvmetad-core.c @@ -753,8 +753,11 @@ static int update_metadata(lvmetad_state *s, const char *name, const char *_vgid dm_hash_insert(s->vgid_to_vgname, vgid, cfgname) && dm_hash_insert(s->vgname_to_vgid, name, (void*) vgid)) ? 1 : 0; - if (retval && oldname && strcmp(name, oldname)) - dm_hash_remove(s->vgname_to_vgid, oldname); + if (retval && oldname && strcmp(name, oldname)) { + const char *vgid_prev = dm_hash_lookup(s->vgname_to_vgid, oldname); + if (vgid_prev && !strcmp(vgid_prev, vgid)) + dm_hash_remove(s->vgname_to_vgid, oldname); + } if (haveseq >= 0 && haveseq < seq) dm_config_destroy(old);