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 775DF1FF0E3 for ; Wed, 18 Nov 2026 21:30:16 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 3FF07219C2; Wed, 18 Nov 2026 21:28:03 +0100 (CET) From: Thomas Lamprecht To: pve-devel@lists.proxmox.com Subject: [PATCH v7 storage 21/43] api: scan: name the portal of an iSCSI path Date: Wed, 18 Nov 2026 21:26:04 +0100 Message-ID: <20261118202646.3017286-22-t.lamprecht@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261118202646.3017286-1-t.lamprecht@proxmox.com> References: <20261118202646.3017286-1-t.lamprecht@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1795033612301 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.166 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) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust 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: Z72QLHWUGDNO2WLDOX7P3CT2KNPNR4EY X-Message-ID-Hash: Z72QLHWUGDNO2WLDOX7P3CT2KNPNR4EY X-MailFrom: t.lamprecht@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: The paths of an iSCSI LUN differ by the portal of their session, which the node reads for its iSCSI status now. Report it as the address of a path in the LUN inventory, as for an NVMe path, so that a failed path of a LUN, with or without a map, names the portal to check. Signed-off-by: Thomas Lamprecht --- src/PVE/API2/Storage/Scan.pm | 3 ++- src/PVE/ISCSI/Topology.pm | 1 + src/PVE/Storage/SAN.pm | 7 +++++++ src/test/run_san_lun_scan_tests.pl | 19 ++++++++++++++++--- 4 files changed, 26 insertions(+), 4 deletions(-) diff --git a/src/PVE/API2/Storage/Scan.pm b/src/PVE/API2/Storage/Scan.pm index f3e2dc1e..343b073a 100644 --- a/src/PVE/API2/Storage/Scan.pm +++ b/src/PVE/API2/Storage/Scan.pm @@ -501,7 +501,8 @@ __PACKAGE__->register_method({ }, address => { description => "The address of the NVMe controller the" - . " path uses.", + . " path uses, or the portal of the iSCSI session of the" + . " path.", type => 'string', optional => 1, }, diff --git a/src/PVE/ISCSI/Topology.pm b/src/PVE/ISCSI/Topology.pm index f975f94f..897bc5a8 100644 --- a/src/PVE/ISCSI/Topology.pm +++ b/src/PVE/ISCSI/Topology.pm @@ -55,6 +55,7 @@ sub sessions($sysfs = undef) { return if !defined($dev); $session->{devices}->{$dev} = { target => $target, + portal => $session->{portal}, session => int($sid), channel => int($channel), id => int($id), diff --git a/src/PVE/Storage/SAN.pm b/src/PVE/Storage/SAN.pm index 6c4dac86..6b92475b 100644 --- a/src/PVE/Storage/SAN.pm +++ b/src/PVE/Storage/SAN.pm @@ -164,6 +164,13 @@ sub scan_luns($cfg) { $row->{'paths-total'} = scalar(@paths); $row->{'paths-active'} = scalar(grep { $_->{state} eq 'running' } @paths); } + # the portal of its session tells an iSCSI path apart, as the address does for NVMe + for my $row (values %rows) { + for my $path (($row->{'path-list'} // [])->@*) { + my $portal = ($sessions->{ basename($path->{device}) } // {})->{portal}; + $path->{address} //= $portal if length($portal // ''); + } + } for my $row (values %rows) { # the devices of a LUN whose requested map is missing do not tell the state of the LUN if (defined($row->{'paths-active'}) && $row->{multipath} ne 'pending') { diff --git a/src/test/run_san_lun_scan_tests.pl b/src/test/run_san_lun_scan_tests.pl index 586fcf44..970ba327 100755 --- a/src/test/run_san_lun_scan_tests.pl +++ b/src/test/run_san_lun_scan_tests.pl @@ -47,7 +47,8 @@ my $generator = Test::MockModule->new('PVE::Multipath::Generator'); $generator->mock(derived_wwids => sub { {} }); $iscsi->mock( device_map => sub { - return { map { $_ => { target => 'iqn.test', lun => 1 } } qw(sdb sdc) }; + return { map { $_ => { target => 'iqn.test', lun => 1, portal => '192.0.2.10:3260' } } + qw(sdb sdc) }; }, ); my @listed; @@ -119,10 +120,14 @@ is($row{'3600plain'}->{'used-by-storage'}, 'direct', 'a storage serving the LUNs } is_deeply( $row{'3600plain'}->{'path-list'}, - [map { { device => $_, state => 'running' } } qw(/dev/sdb /dev/sdc)], - 'without a map, the devices of a LUN are its paths', + [ + map { { device => $_, state => 'running', address => '192.0.2.10:3260' } } + qw(/dev/sdb /dev/sdc) + ], + 'without a map, the devices of a LUN are its paths, with the portal of their session', ); is($row{'3600plain'}->{state}, 'optimal', 'their kernel state gives the health of the LUN'); +ok(!exists($row{'3600map'}->{'path-list'}->[0]->{address}), 'no portal without a session'); { local $device_state{sdc} = 'transport-offline'; my ($down) = grep { $_->{wwid} eq '3600plain' } PVE::Storage::SAN::scan_luns($cfg)->@*; @@ -142,6 +147,14 @@ is($row{'3600plain'}->{state}, 'optimal', 'their kernel state gives the health o ok(!exists($pending->{state}), 'but has no state from them'); $mp->mock(list_etc_multipath_wwids => sub { [] }); } +{ + # an iSCSI path of a map + my $sessions = PVE::ISCSI::Topology::device_map(); + $iscsi->mock(device_map => sub { +{ %$sessions, sdd => { %{ $sessions->{sdb} } } } }); + my ($map) = grep { $_->{wwid} eq '3600map' } PVE::Storage::SAN::scan_luns($cfg)->@*; + is($map->{'path-list'}->[0]->{address}, '192.0.2.10:3260', 'names the portal of its session'); + $iscsi->mock(device_map => sub { $sessions }); +} { # a LUN with a single path and no map $id->mock(path_wwid => sub { $_[1] eq 'sdb' ? '3600plain' : undef });