]> git.proxmox.com Git - pve-cluster.git/commitdiff
cfs_lock: swap checks for specific errors with $got_lock
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 9 Nov 2017 08:47:25 +0000 (09:47 +0100)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Thu, 9 Nov 2017 09:30:29 +0000 (10:30 +0100)
We checked if a specific error was set or, respectively, not set to
know if we got the lock or not.
The check if we may unlock again was negated and thus could lead to
problems, in specific - rather unlikely - cases.

Use the by the previous patch added $got_lock variable, which only
gets set when we really got the lock, instead.

While refactoring for the new variable, set the $noerr parameter of
check_cfs_quorum() as we do not want to die here.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
data/PVE/Cluster.pm

index 94db5918efde1c817c7444b992b56fe8784c5410..1dd29b26a7b216a07cd099082b620bf621c22363 100644 (file)
@@ -911,14 +911,9 @@ my $cfs_lock = sub {
 
     alarm(0);
 
-    if ($err && ($err eq "got lock request timeout\n") &&
-       !check_cfs_quorum()){
-       $err = "$msg: no quorum!\n";
-    }
+    $err = "$msg: no quorum!\n" if !$got_lock && !check_cfs_quorum(1);
 
-    if (!$err || $err !~ /^got lock timeout -/) {
-       rmdir $filename; # cfs unlock
-    }
+    rmdir $filename if $got_lock; # if we held the lock always unlock again
 
     if ($err) {
         $@ = $err;