[pve-devel] r5630 - pve-storage/pve2/PVE

svn-commits at proxmox.com svn-commits at proxmox.com
Fri Feb 25 13:21:29 CET 2011


Author: dietmar
Date: 2011-02-25 13:21:29 +0100 (Fri, 25 Feb 2011)
New Revision: 5630

Modified:
   pve-storage/pve2/PVE/Storage.pm
Log:
implement cluster_lock_storage


Modified: pve-storage/pve2/PVE/Storage.pm
===================================================================
--- pve-storage/pve2/PVE/Storage.pm	2011-02-25 12:20:05 UTC (rev 5629)
+++ pve-storage/pve2/PVE/Storage.pm	2011-02-25 12:21:29 UTC (rev 5630)
@@ -572,8 +572,19 @@
 sub cluster_lock_storage {
     my ($storeid, $shared, $timeout, $func, @param) = @_;
 
-    die "cluster lock not implemented";
-
+    my $locktext = "local storage $storeid";
+    my $res;
+    if (!$shared) {
+	my $lockid = "pve-storage-$storeid";
+	my $lockdir = "/var/lock/pve-manager";
+	mkdir $lockdir;
+	$res = PVE::Tools::lock_file("$lockdir/$lockid", $timeout, $locktext, $func, @param); 
+	die $@ if $@;
+    } else {
+	$res = PVE::Cluster::cfs_lock_storage($storeid, $timeout, $locktext, $func, @param);
+	die $@ if $@;
+    }	
+    return $res;
 }
 
 sub storage_config {
@@ -1141,7 +1152,7 @@
     activate_storage ($cfg, $storeid);
 
     # lock shared storage
-    return cluster_lock_storage ($storeid, $scfg->{shared}, undef, sub {
+    return cluster_lock_storage($storeid, $scfg->{shared}, undef, sub {
 
 	if ($scfg->{type} eq 'dir' || $scfg->{type} eq 'nfs') {
 
@@ -1236,7 +1247,7 @@
     activate_storage ($cfg, $storeid);
 
     # lock shared storage
-    cluster_lock_storage ($storeid, $scfg->{shared}, undef, sub {
+    cluster_lock_storage($storeid, $scfg->{shared}, undef, sub {
 
 	if ($scfg->{type} eq 'dir' || $scfg->{type} eq 'nfs') {
 	    my $path = path ($cfg, $volid); 




More information about the pve-devel mailing list