fix sort luns numerically

This commit is contained in:
Beam 2017-10-12 15:23:59 +02:00
parent ac809e4c71
commit 3797983e1a
1 changed files with 4 additions and 4 deletions

View File

@ -400,13 +400,13 @@ sub freenas_get_first_available_lunid {
push(@luns, $item->{'iscsi_lunid'}) if ($item->{'iscsi_target'} == $target_id); push(@luns, $item->{'iscsi_lunid'}) if ($item->{'iscsi_target'} == $target_id);
} }
my @sorted_luns = sort(@luns); my @sorted_luns = sort { $a <=> $b } @luns;
my $lun_id = 0; my $lun_id = 0;
# find the first hole, if not, give the +1 of the last lun # find the first hole, if not, give the +1 of the last lun
foreach my $lun ( @sorted_luns ) { foreach my $lun ( @sorted_luns ) {
last if $lun != $lun_id; last if $lun != $lun_id;
$lun_id = $lun_id + 1; $lun_id = $lun_id + 1;
} }
syslog("info","FreeNAS::API::freenas_get_first_available_lunid : return $lun_id"); syslog("info","FreeNAS::API::freenas_get_first_available_lunid : return $lun_id");