From d1e7ac11de56a4e4a2aea548a017bce87e17a4bb Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Thu, 18 Jun 2015 06:21:38 +0200 Subject: [PATCH] drbd: improve workaround for set_drbdsetup_props --- PVE/Storage/DRBDPlugin.pm | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/PVE/Storage/DRBDPlugin.pm b/PVE/Storage/DRBDPlugin.pm index e1d6a60..91ff842 100644 --- a/PVE/Storage/DRBDPlugin.pm +++ b/PVE/Storage/DRBDPlugin.pm @@ -188,7 +188,18 @@ sub alloc_image { ($rc, $res) = $hdl->auto_deploy($name, $redundancy, 0, 0); check_drbd_rc($rc->[0]); - sleep(5); # else we get split brain?! + # hack: this is required to avoid bugs with set_drbdsetup_props(), + # which can result in a split brain if we do not wait. + # Note: wait until all volumes have cstate:deploy + my $max_wait = 15; + for (my $i = 0; $i < $max_wait; $i++) { + ($rc, $res) = $hdl->list_assignments([], [$name], 0, { "cstate:deploy" => "true" }, []); + check_drbd_rc($rc->[0]); + my $len = scalar(@$res); + last if $len == $redundancy; + sleep(1); + } + sleep(1); # another sleep - it does not work without -no idea why? ($rc, $res) = $hdl->set_drbdsetup_props( {