[pve-devel] r5472 - pve-cluster/trunk/data
svn-commits at proxmox.com
svn-commits at proxmox.com
Tue Feb 1 12:44:52 CET 2011
Author: dietmar
Date: 2011-02-01 12:44:52 +0100 (Tue, 01 Feb 2011)
New Revision: 5472
Modified:
pve-cluster/trunk/data/README
Log:
Modified: pve-cluster/trunk/data/README
===================================================================
--- pve-cluster/trunk/data/README 2011-02-01 11:10:45 UTC (rev 5471)
+++ pve-cluster/trunk/data/README 2011-02-01 11:44:52 UTC (rev 5472)
@@ -325,7 +325,29 @@
messages immediately. We can safely discard this queue at
configuration change.
+File Locking
+============
+We implement a simple lock-file based locking mechanism on top of the
+distributed file system. You can create/acquire a lock with:
+
+ $filename = "/etc/pve/priv/lock/<A-LOCK-NAME>";
+ while(!(mkdir $filename)) {
+ (utime 0, 0, $filename); # cfs unlock request
+ sleep(1);
+ }
+ /* got the lock */
+
+If above command succeed, you got the lock for 120 seconds (hard coded
+time limit). The 'mkdir' command is atomic and only succeed if the
+directory does not exist. The 'utime 0 0' triggers a cluster wide
+test, and removes $filename if it is older than 120 seconds. This test
+does not use the mtime stored inside the file system, because there can
+be a time drift between nodes. Instead each node stores the local time when
+it first see a lock file. This time is used to calculate the age of
+the lock.
+
+
References
==========
More information about the pve-devel
mailing list