[pve-devel] [PATCH pve-cluster 1/2] add function to lock a domain

Thomas Lamprecht t.lamprecht at proxmox.com
Fri Sep 25 17:50:05 CEST 2015


This can be used to execute code on an 'action domain' basis.
E.g.: if there are actions that cannot be run simultaneously even if
they, for example, don't access a common file and maybe also spread
across different packages we can now secure the consistence of said
actions on an 'action domain' basis.

The need to use a dirty hack like cfs_lock_storage with some
arbitrary storage name becomes obsolete. Also the code behaviour
and meaning becomes clearer.

Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
---
 data/PVE/Cluster.pm | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/data/PVE/Cluster.pm b/data/PVE/Cluster.pm
index a1b438c..55ccdb4 100644
--- a/data/PVE/Cluster.pm
+++ b/data/PVE/Cluster.pm
@@ -927,6 +927,14 @@ sub cfs_lock_storage {
     &$cfs_lock($lockid, $timeout, $code, @param);
 }
 
+sub cfs_lock_domain {
+    my ($domainname, $timeout, $code, @param) = @_;
+
+    my $lockid = "domain-$domainname";
+
+    &$cfs_lock($lockid, $timeout, $code, @param);
+}
+
 my $log_levels = {
     "emerg" => 0,
     "alert" => 1,
-- 
2.1.4





More information about the pve-devel mailing list