[pve-devel] [PATCH 2/5] DRBD: Remove search loop, limit results via the query.

Philipp Marek philipp.marek at linbit.com
Thu Oct 8 10:24:46 CEST 2015


---
 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 565fb4c..91addc5 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' });
-- 
2.6.1




More information about the pve-devel mailing list