From 16e2a5aa3b7947af3f5ca85bc875b08a29b980f7 Mon Sep 17 00:00:00 2001 From: Alasdair Kergon Date: Wed, 30 Jan 2008 16:18:37 +0000 Subject: [PATCH] only read labels once between each lock event --- lib/cache/lvmcache.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/cache/lvmcache.c b/lib/cache/lvmcache.c index 59011f6ee..3bb7b63e7 100644 --- a/lib/cache/lvmcache.c +++ b/lib/cache/lvmcache.c @@ -225,6 +225,16 @@ static int _info_is_valid(struct lvmcache_info *info) if (info->status & CACHE_INVALID) return 0; + /* + * The caller must hold the VG lock to manipulate metadata. + * In a cluster, remote nodes sometimes read metadata in the + * knowledge that the controlling node is holding the lock. + * So if the VG appears to be unlocked here, it should be safe + * to use the cached value. + */ + if (info->vginfo && !vgname_is_locked(info->vginfo->vgname)) + return 1; + if (!(info->status & CACHE_LOCKED)) return 0;