From 046fd4cb6120c2bdb9c347d03959af1fef550c15 Mon Sep 17 00:00:00 2001 From: Philipp Marek Date: Thu, 8 Oct 2015 10:24:46 +0200 Subject: [PATCH] DRBD: Remove search loop, limit results via the query. --- PVE/Storage/DRBDPlugin.pm | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/PVE/Storage/DRBDPlugin.pm b/PVE/Storage/DRBDPlugin.pm index b780829..cca48ce 100644 --- a/PVE/Storage/DRBDPlugin.pm +++ b/PVE/Storage/DRBDPlugin.pm @@ -304,15 +304,11 @@ sub activate_volume { my $hdl = connect_drbdmanage_service(); my $nodename = PVE::INotify::nodename(); - my ($rc, $res) = $hdl->list_assignments([$nodename], [], 0, {}, []); + my ($rc, $res) = $hdl->list_assignments([$nodename], [$volname], 0, {}, []); check_drbd_res($rc); - foreach my $entry (@$res) { - my ($node, $res_name, $props, $voldata) = @$entry; - if (($node eq $nodename) && ($res_name eq $volname)) { - return undef; # assignment already exists - } - } +# assignment already exists? + return undef if @$res; # create diskless assignment ($rc, $res) = $hdl->assign($nodename, $volname, { diskless => 'true' });