summaryrefslogtreecommitdiffstats
path: root/daemons/clvmd/lvm-functions.c
diff options
context:
space:
mode:
authorMilan Broz <mbroz@redhat.com>2010-01-05 16:09:33 +0000
committerMilan Broz <mbroz@redhat.com>2010-01-05 16:09:33 +0000
commit0e06c92fdf1973bf8a8e0096b7beaf6fc687f10e (patch)
treeccb8eee0ad22a7a515de951c2f4d49ce7f926297 /daemons/clvmd/lvm-functions.c
parentc9118a1d20b27bcd51a7396881128381115a230f (diff)
downloadlvm2-0e06c92fdf1973bf8a8e0096b7beaf6fc687f10e.tar.gz
lvm2-0e06c92fdf1973bf8a8e0096b7beaf6fc687f10e.tar.xz
lvm2-0e06c92fdf1973bf8a8e0096b7beaf6fc687f10e.zip
Propagate commit and revert metadata event to other nodes in cluster.
This patch tries to correctly track changes in lvmcache related to commit/revert. For vg_commit: if there is cached precommitted metadata, after successfull commit these metadata must be tracked as committed. For vg_revert: remote nodes must drop precommitted metadata and its flag in lvmcache. (N.B. Patch do not touch LV locks here in any way.) All this machinery is needed to properly solve remote node cache invalidaton which cause several problems recently observed.
Diffstat (limited to 'daemons/clvmd/lvm-functions.c')
-rw-r--r--daemons/clvmd/lvm-functions.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/daemons/clvmd/lvm-functions.c b/daemons/clvmd/lvm-functions.c
index ad6b924c..afe93e2f 100644
--- a/daemons/clvmd/lvm-functions.c
+++ b/daemons/clvmd/lvm-functions.c
@@ -680,6 +680,7 @@ static void drop_vg_locks()
*/
void do_lock_vg(unsigned char command, unsigned char lock_flags, char *resource)
{
+ uint32_t lock_cmd = command;
char *vgname = resource + 2;
DEBUGLOG("do_lock_vg: resource '%s', cmd = %s, flags = %s, memlock = %d\n",
@@ -691,9 +692,29 @@ void do_lock_vg(unsigned char command, unsigned char lock_flags, char *resource)
return;
}
+ lock_cmd &= (LCK_SCOPE_MASK | LCK_TYPE_MASK | LCK_HOLD);
+
+ /*
+ * Check if LCK_CACHE should be set. All P_ locks except # are cache related.
+ */
+ if (strncmp(resource, "P_#", 3) && !strncmp(resource, "P_", 2))
+ lock_cmd |= LCK_CACHE;
+
pthread_mutex_lock(&lvm_lock);
- DEBUGLOG("Dropping metadata for VG %s\n", vgname);
- lvmcache_drop_metadata(vgname, 0);
+ switch (lock_cmd) {
+ case LCK_VG_COMMIT:
+ DEBUGLOG("vg_commit notification for VG %s\n", vgname);
+ lvmcache_commit_metadata(vgname);
+ break;
+ case LCK_VG_REVERT:
+ DEBUGLOG("vg_revert notification for VG %s\n", vgname);
+ lvmcache_drop_metadata(vgname, 1);
+ break;
+ case LCK_VG_DROP_CACHE:
+ default:
+ DEBUGLOG("Invalidating cached metadata for VG %s\n", vgname);
+ lvmcache_drop_metadata(vgname, 0);
+ }
pthread_mutex_unlock(&lvm_lock);
}