From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id 7A62D1FF13C for ; Thu, 25 Jun 2026 18:41:40 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id DC74C59D; Thu, 25 Jun 2026 18:41:29 +0200 (CEST) From: "Max R. Carrara" To: pve-devel@lists.proxmox.com Subject: [PATCH pve-storage 5/9] luncmd: lio: modernize & clean up `list_view()` and `list_lun()` subs Date: Thu, 25 Jun 2026 18:40:57 +0200 Message-ID: <20260625164110.706694-6-m.carrara@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260625164110.706694-1-m.carrara@proxmox.com> References: <20260625164110.706694-1-m.carrara@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1782405676365 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.080 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: NZUGLICNYOHPK7PJO6SCWDRHXQO4XCS5 X-Message-ID-Hash: NZUGLICNYOHPK7PJO6SCWDRHXQO4XCS5 X-MailFrom: m.carrara@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Make the `list_view()` and `list_lun()` subs "proper" private subroutines instead of lexically-scoped sub references. Also improve the code style along the way. Signed-off-by: Max R. Carrara --- src/PVE/Storage/LunCmd/LIO.pm | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/PVE/Storage/LunCmd/LIO.pm b/src/PVE/Storage/LunCmd/LIO.pm index abe0454b..483e2459 100644 --- a/src/PVE/Storage/LunCmd/LIO.pm +++ b/src/PVE/Storage/LunCmd/LIO.pm @@ -244,49 +244,49 @@ my sub extract_volname { } # retrieves the LUN index for a particular object -my $list_view = sub { +my sub list_view { my ($scfg, $config, $timeout, $method, @params) = @_; - my $lun = undef; - my $object = $params[0]; + my $object = shift @params; my $volname = extract_volname($scfg, $config, $object); + return if !defined($volname); # nothing to search for.. + my $id = "$scfg->{portal}.$scfg->{target}"; my $target = $config->{$id}; - return undef if !defined($volname); # nothing to search for.. - - foreach my $lun (@{ $target->{luns} }) { + for my $lun ($target->{luns}->@*) { if ($lun->{storage_object} eq "$BACKSTORE/$volname") { return $lun->{index}; } } - return $lun; -}; + return; +} -# determines, if the given object exists on the portal -my $list_lun = sub { +# determines if the given object exists on the portal +my sub list_lun { my ($scfg, $config, $timeout, $method, @params) = @_; - my $object = $params[0]; + my $object = shift @params; my $volname = extract_volname($scfg, $config, $object); + my $id = "$scfg->{portal}.$scfg->{target}"; my $target = $config->{$id}; - foreach my $lun (@{ $target->{luns} }) { + for my $lun ($target->{luns}->@*) { if ($lun->{storage_object} eq "$BACKSTORE/$volname") { return $object; } } - return undef; -}; + return; +} # adds a new LUN to the target my $create_lun = sub { my ($scfg, $config, $timeout, $method, @params) = @_; - if ($list_lun->($scfg, $config, $timeout, $method, @params)) { + if (list_lun($scfg, $config, $timeout, $method, @params)) { die "$params[0]: LUN already exists!"; } @@ -392,8 +392,8 @@ my %lun_cmd_map = ( import_lu => $import_lun, modify_lu => $modify_lun, add_view => $add_view, - list_view => $list_view, - list_lu => $list_lun, + list_view => sub { list_view(@_) }, + list_lu => sub { list_lun(@_) }, ); sub run_lun_command { -- 2.47.3