commit 8f17dc8027f1d9fd188468c26eb8c0a9957cc9cb Author: Peter Rajnoha Date: Tue May 14 11:04:52 2013 +0200 lvm2-2_02_99-fix-possible-race-in-lvmetad-remove_metadata.patch --- WHATS_NEW | 1 + daemons/lvmetad/lvmetad-core.c | 14 +++++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/WHATS_NEW b/WHATS_NEW index 4728466..20a8125 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,5 +1,6 @@ Version 2.02.99 - =================================== + Fix possible race while removing metadata from lvmetad. Fix possible deadlock when querying and updating lvmetad at the same time. Avoid a global lock in pvs when lvmetad is in use. Fix crash in pvscan --cache -aay triggered by non-mda PV. diff --git a/daemons/lvmetad/lvmetad-core.c b/daemons/lvmetad/lvmetad-core.c index 3f417da..fed9296 100644 --- a/daemons/lvmetad/lvmetad-core.c +++ b/daemons/lvmetad/lvmetad-core.c @@ -605,19 +605,23 @@ static int remove_metadata(lvmetad_state *s, const char *vgid, int update_pvids) lock_vgid_to_metadata(s); old = dm_hash_lookup(s->vgid_to_metadata, vgid); oldname = dm_hash_lookup(s->vgid_to_vgname, vgid); - unlock_vgid_to_metadata(s); - if (!old) + if (!old) { + unlock_vgid_to_metadata(s); return 0; + } + assert(oldname); - if (update_pvids) - /* FIXME: What should happen when update fails */ - update_pvid_to_vgid(s, old, "#orphan", 0); /* need to update what we have since we found a newer version */ dm_hash_remove(s->vgid_to_metadata, vgid); dm_hash_remove(s->vgid_to_vgname, vgid); dm_hash_remove(s->vgname_to_vgid, oldname); + unlock_vgid_to_metadata(s); + + if (update_pvids) + /* FIXME: What should happen when update fails */ + update_pvid_to_vgid(s, old, "#orphan", 0); dm_config_destroy(old); return 1; }