[pve-devel] [PATCH cluster v4 2/4] cfs_lock: swap checks for specific errors with $got_lock

Thomas Lamprecht t.lamprecht at proxmox.com
Thu Nov 9 09:47:25 CET 2017


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 at proxmox.com>
---
 data/PVE/Cluster.pm | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/data/PVE/Cluster.pm b/data/PVE/Cluster.pm
index 94db591..1dd29b2 100644
--- a/data/PVE/Cluster.pm
+++ b/data/PVE/Cluster.pm
@@ -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;
-- 
2.11.0





More information about the pve-devel mailing list