From 3d6af3e35e3de157d618f922f61194928aa7f11d Mon Sep 17 00:00:00 2001 From: Alasdair Kergon Date: Fri, 9 May 2008 15:13:20 +0000 Subject: [PATCH] Add missing mutex around clvmd lvmcache_drop_metadata library call. --- WHATS_NEW | 5 +++-- daemons/clvmd/clvmd-command.c | 8 ++++++-- daemons/clvmd/lvm-functions.c | 10 ++++++++++ daemons/clvmd/lvm-functions.h | 1 + lib/cache/lvmcache.c | 2 +- 5 files changed, 21 insertions(+), 5 deletions(-) diff --git a/WHATS_NEW b/WHATS_NEW index af43737ee..14864bc4d 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,13 +1,14 @@ Version 2.02.38 - ================================= - Fix uninitialised mutex in clvmd if all daemons are not running at startup. Make clvmd-cman use a hash rather than an array for node updown info. Check lv_count in vg_validate. Add --prefixes to reporting tools for field name prefix output format. Version 2.02.37 - ================================= - Avoid unnecessary unlock attempts with LCK_CACHE pseudo-locks. + Add missing mutex around clvmd lvmcache_drop_metadata library call. + Fix uninitialised mutex in clvmd if all daemons are not running at startup. + Avoid using DLM locks with LCK_CACHE type P_ lock requests. When asked to drop cached committed VG metadata, invalidate cached PV labels. Drop metadata cache before writing precommitted metadata instead of after. Don't touch /dev in vgrename if activation is disabled. diff --git a/daemons/clvmd/clvmd-command.c b/daemons/clvmd/clvmd-command.c index b47f52732..8e544e901 100644 --- a/daemons/clvmd/clvmd-command.c +++ b/daemons/clvmd/clvmd-command.c @@ -122,7 +122,7 @@ int do_command(struct local_client *client, struct clvm_header *msg, int msglen, if (strcmp(lockname, "P_#global") == 0) do_refresh_cache(); else if (strncmp(lockname, "P_", 2) == 0) - lvmcache_drop_metadata(lockname + 2); + drop_metadata(lockname + 2); break; @@ -253,7 +253,11 @@ int do_pre_command(struct local_client *client) break; case CLVMD_CMD_LOCK_VG: - status = lock_vg(client); + lockname = &args[2]; + /* Do not use lock for cache related commands */ + if (!strncmp(lockname, "V_", 2) || + !strcmp(lockname, "P_#global")) + status = lock_vg(client); break; case CLVMD_CMD_LOCK_LV: diff --git a/daemons/clvmd/lvm-functions.c b/daemons/clvmd/lvm-functions.c index 3cfce8e34..08c370bea 100644 --- a/daemons/clvmd/lvm-functions.c +++ b/daemons/clvmd/lvm-functions.c @@ -499,6 +499,16 @@ static void drop_vg_locks() DEBUGLOG("vgs fclose failed: %s\n", strerror(errno)); } +/* + * Drop lvmcache metadata + */ +void drop_metadata(const char *vgname) +{ + pthread_mutex_lock(&lvm_lock); + lvmcache_drop_metadata(vgname); + pthread_mutex_unlock(&lvm_lock); +} + /* * Ideally, clvmd should be started before any LVs are active * but this may not be the case... diff --git a/daemons/clvmd/lvm-functions.h b/daemons/clvmd/lvm-functions.h index 01d5d8317..bf42dbe63 100644 --- a/daemons/clvmd/lvm-functions.h +++ b/daemons/clvmd/lvm-functions.h @@ -33,5 +33,6 @@ extern int hold_unlock(char *resource); extern int hold_lock(char *resource, int mode, int flags); extern void unlock_all(void); extern char *get_last_lvm_error(void); +extern void drop_metadata(const char *vgname); #endif diff --git a/lib/cache/lvmcache.c b/lib/cache/lvmcache.c index 3fc5c97ad..bc0b3d32f 100644 --- a/lib/cache/lvmcache.c +++ b/lib/cache/lvmcache.c @@ -158,7 +158,7 @@ static void _drop_metadata(const char *vgname) void lvmcache_drop_metadata(const char *vgname) { /* For VG_ORPHANS, we need to invalidate all labels on orphan PVs. */ - if (strcmp(vgname, VG_ORPHANS)) { + if (!strcmp(vgname, VG_ORPHANS)) { _drop_metadata(FMT_TEXT_ORPHAN_VG_NAME); _drop_metadata(FMT_LVM1_ORPHAN_VG_NAME); _drop_metadata(FMT_POOL_ORPHAN_VG_NAME);