[pve-devel] r6388 - in pve-cluster/trunk/data: . PVE
svn-commits at proxmox.com
svn-commits at proxmox.com
Mon Aug 1 13:33:10 CEST 2011
Author: dietmar
Date: 2011-08-01 13:33:10 +0200 (Mon, 01 Aug 2011)
New Revision: 6388
Modified:
pve-cluster/trunk/data/ChangeLog
pve-cluster/trunk/data/PVE/Cluster.pm
Log:
cfs_lock improvements
Modified: pve-cluster/trunk/data/ChangeLog
===================================================================
--- pve-cluster/trunk/data/ChangeLog 2011-08-01 09:29:24 UTC (rev 6387)
+++ pve-cluster/trunk/data/ChangeLog 2011-08-01 11:33:10 UTC (rev 6388)
@@ -1,3 +1,9 @@
+2011-08-01 Proxmox Support Team <support at proxmox.com>
+
+ * PVE/Cluster.pm (check_cfs_quorum): helper to check quorum
+ (cfs_lock_file): remove $text parameter
+ (cfs_lock_storage): remove $text parameter
+
2011-06-29 Proxmox Support Team <support at proxmox.com>
* PVE/Cluster.pm (run_silent_cmd): supress output when running
Modified: pve-cluster/trunk/data/PVE/Cluster.pm
===================================================================
--- pve-cluster/trunk/data/PVE/Cluster.pm 2011-08-01 09:29:24 UTC (rev 6387)
+++ pve-cluster/trunk/data/PVE/Cluster.pm 2011-08-01 11:33:10 UTC (rev 6388)
@@ -2,6 +2,7 @@
use strict;
use POSIX;
+use File::stat qw();
use Socket;
use Storable qw(dclone);
use IO::File;
@@ -73,6 +74,13 @@
}
}
+sub check_cfs_quorum {
+ # note: -w $lockdir always return 1 for root, so wee need
+ # to use File::stat here
+ my $st = File::stat::stat($lockdir);
+ return (($st->mode & 0200) != 0);
+}
+
sub check_cfs_is_mounted {
my ($noerr) = @_;
@@ -727,21 +735,25 @@
}
my $cfs_lock = sub {
- my ($lockid, $timeout, $text, $code, @param) = @_;
+ my ($lockid, $timeout, $code, @param) = @_;
my $res;
- # fixed timeout: cfs locks have a timeout of 120
- # using 60 gives us another 60 seconds to abort the task
-
+ # this timeout is for aquire the lock
$timeout = 10 if !$timeout;
my $filename = "$lockdir/$lockid";
+ my $msg = "can't aquire cfs lock '$lockid'";
+
eval {
- local $SIG{ALRM} = sub { die "can't aquire lock for $text '$lockid': got timeout\n"; };
+ if (! -d $lockdir) {
+ die "$msg: pve cluster filesystem not online.\n";
+ }
+ local $SIG{ALRM} = sub { die "got lock request timeout\n"; };
+
alarm ($timeout);
if (!(mkdir $filename)) {
@@ -751,13 +763,13 @@
(utime 0, 0, $filename); # cfs unlock request
} else {
print STDERR " OK\n";
- last;
+ last;
}
sleep(1);
}
}
- # fixed timeout: cfs locks have a timeout of 120
+ # fixed command timeout: cfs locks have a timeout of 120
# using 60 gives us another 60 seconds to abort the task
alarm(60);
local $SIG{ALRM} = sub { die "got lock timeout - aborting command\n"; };
@@ -771,6 +783,11 @@
alarm(0);
+ if ($err && ($err eq "got lock request timeout\n") &&
+ !check_cfs_quorum()){
+ $err = "$msg: no quorum!\n";
+ }
+
if (!$err || $err !~ /^got lock timeout -/) {
rmdir $filename; # cfs unlock
}
@@ -786,22 +803,22 @@
};
sub cfs_lock_file {
- my ($filename, $timeout, $text, $code, @param) = @_;
+ my ($filename, $timeout, $code, @param) = @_;
my $info = $observed->{$filename} || die "unknown file '$filename'";
my $lockid = "file-$filename";
$lockid =~ s/[.\/]/_/g;
- &$cfs_lock($lockid, $timeout, $text, $code, @param);
+ &$cfs_lock($lockid, $timeout, $code, @param);
}
sub cfs_lock_storage {
- my ($storeid, $timeout, $text, $code, @param) = @_;
+ my ($storeid, $timeout, $code, @param) = @_;
my $lockid = "storage-$storeid";
- &$cfs_lock($lockid, $timeout, $text, $code, @param);
+ &$cfs_lock($lockid, $timeout, $code, @param);
}
my $log_levels = {
More information about the pve-devel
mailing list