From 3797983e1a630b0c082cd7f877c195b4cb9c630a Mon Sep 17 00:00:00 2001 From: Beam Date: Thu, 12 Oct 2017 15:23:59 +0200 Subject: [PATCH] fix sort luns numerically --- perl5/PVE/Storage/LunCmd/FreeNAS.pm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/perl5/PVE/Storage/LunCmd/FreeNAS.pm b/perl5/PVE/Storage/LunCmd/FreeNAS.pm index 91506c9..40414b0 100644 --- a/perl5/PVE/Storage/LunCmd/FreeNAS.pm +++ b/perl5/PVE/Storage/LunCmd/FreeNAS.pm @@ -400,13 +400,13 @@ sub freenas_get_first_available_lunid { push(@luns, $item->{'iscsi_lunid'}) if ($item->{'iscsi_target'} == $target_id); } - my @sorted_luns = sort(@luns); - my $lun_id = 0; + my @sorted_luns = sort { $a <=> $b } @luns; + my $lun_id = 0; # find the first hole, if not, give the +1 of the last lun foreach my $lun ( @sorted_luns ) { - last if $lun != $lun_id; - $lun_id = $lun_id + 1; + last if $lun != $lun_id; + $lun_id = $lun_id + 1; } syslog("info","FreeNAS::API::freenas_get_first_available_lunid : return $lun_id");