From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [45.144.208.40]) by lore.proxmox.com (Postfix) with ESMTPS id B6D8E1FF0E3 for ; Tue, 04 Aug 2026 11:08:34 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 55A7A21627; Tue, 04 Aug 2026 11:08:25 +0200 (CEST) From: Dietmar Maurer To: pve-devel@lists.proxmox.com Subject: [PATCH storage 1/7] iscsi: discovery: do not stop early on a foreign target Date: Tue, 4 Aug 2026 11:08:13 +0200 Message-ID: <20260804090819.2136483-2-dietmar@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260804090819.2136483-1-dietmar@proxmox.com> References: <20260804090819.2136483-1-dietmar@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 2 AWL -0.119 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) KAM_LAZY_DOMAIN_SECURITY 1 Sending domain does not have any anti-forgery methods RDNS_NONE 1.274 Delivered to internal network by a host with no rDNS SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_NONE 0.001 SPF: sender does not publish an SPF Record Message-ID-Hash: VYA55TEG4S7BUJHT4MHGWQGPJAPLT6U5 X-Message-ID-Hash: VYA55TEG4S7BUJHT4MHGWQGPJAPLT6U5 X-MailFrom: dietmar@zilli.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: sendtargets returns every portal of a target in one call, so querying further portals is pointless once the requested target showed up. The check only looked at whether any target came back, so a portal that serves other targets aborted the loop before the portals that actually serve the requested one were queried. Discovery without a requested target now queries all given portals, which is what a caller enumerating a SAN wants. Signed-off-by: Dietmar Maurer --- src/PVE/Storage/ISCSIPlugin.pm | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/PVE/Storage/ISCSIPlugin.pm b/src/PVE/Storage/ISCSIPlugin.pm index 801b5d1..807adbd 100644 --- a/src/PVE/Storage/ISCSIPlugin.pm +++ b/src/PVE/Storage/ISCSIPlugin.pm @@ -134,6 +134,7 @@ sub iscsi_discovery { for my $portal ($portals->@*) { next if !iscsi_test_portal($target_in, $portal, $cache); # fixme: raise exception here? + my $target_found = 0; my $cmd = [$ISCSIADM, '--mode', 'discovery', '--type', 'sendtargets', '--portal', $portal]; eval { run_command( @@ -146,13 +147,16 @@ sub iscsi_discovery { # one target can have more than one portal (multipath) # and sendtargets should return all of them in single call push @{ $res->{$target} }, $portal; + + $target_found = 1 if defined($target_in) && $target eq $target_in; } }, ); }; - # In case of multipath we can stop after receiving targets from any available portal - last if scalar(keys %$res) > 0; + # sendtargets returns all portals of a target, so one hit is enough. Without a + # requested target, query every portal to get the full picture + last if $target_found; } return $res; -- 2.47.3