From: Thomas Lamprecht <t.lamprecht@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH v2 storage 06/17] api: scan: san-luns: attribute NVMe namespaces to storage
Date: Wed, 18 Nov 2026 21:42:25 +0100 [thread overview]
Message-ID: <20261118204302.3100813-7-t.lamprecht@proxmox.com> (raw)
In-Reply-To: <20261118204302.3100813-1-t.lamprecht@proxmox.com>
The SAN LUN inventory lists NVMe namespaces with their subsystem, but
without relation to an NVMe over Fabrics storage. Expect one path per
portal of the storage that connects the subsystem of a namespace, so
that a namespace with fewer paths shows as degraded.
A namespace counts as used by the LVM storage that has it as base
volume, else by the storage of its subsystem if that one serves the
namespaces as images.
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---
src/PVE/API2/Storage/Scan.pm | 9 +++++----
src/PVE/Storage/SAN.pm | 16 +++++++++++++---
src/test/run_san_lun_scan_tests.pl | 28 ++++++++++++++++++++++++++++
3 files changed, 46 insertions(+), 7 deletions(-)
diff --git a/src/PVE/API2/Storage/Scan.pm b/src/PVE/API2/Storage/Scan.pm
index 84848847..7d3fd242 100644
--- a/src/PVE/API2/Storage/Scan.pm
+++ b/src/PVE/API2/Storage/Scan.pm
@@ -499,8 +499,9 @@ __PACKAGE__->register_method({
'paths-expected' => {
description => "The number of paths the LUN should have on this node: the"
. " highest of the count of its multipath entry and, for each managed"
- . " iSCSI storage of the LUN, the number of its portals. Absent if no"
- . " count is known.",
+ . " iSCSI storage of the LUN, the number of its portals. For a namespace"
+ . " of an NVMe over Fabrics storage, the number of its portals. Absent if"
+ . " no count is known.",
type => 'integer',
optional => 1,
},
@@ -579,8 +580,8 @@ __PACKAGE__->register_method({
},
'used-by-storage' => {
description => "The storage that uses the LUN: as its base volume or"
- . " through the volume group on it, or as an iSCSI storage that serves the"
- . " LUNs of its target as images.",
+ . " through the volume group on it, or as an iSCSI or NVMe over Fabrics"
+ . " storage that serves the LUNs of its target or subsystem as images.",
type => 'string',
optional => 1,
},
diff --git a/src/PVE/Storage/SAN.pm b/src/PVE/Storage/SAN.pm
index 86469f5c..abf992d9 100644
--- a/src/PVE/Storage/SAN.pm
+++ b/src/PVE/Storage/SAN.pm
@@ -16,6 +16,7 @@ use PVE::Multipath;
use PVE::Multipath::Config;
use PVE::Multipath::Generator;
use PVE::Multipath::Identity;
+use PVE::NVMeOF;
use PVE::Storage;
use PVE::Storage::LVMPlugin;
@@ -42,7 +43,8 @@ sub scan_luns($cfg) {
PVE::Multipath::Config::wwids_for_node($mpcfg, PVE::INotify::nodename())->@*;
my %listed = map { $_ => 1 } PVE::Multipath::list_etc_multipath_wwids()->@*;
my $derived = PVE::Multipath::Generator::derived_wwids($cfg, $ids);
- my (%storage, %expected, %vg_owner, %target_owner, %base_owner, %targets, %paths, %unmapped);
+ my (%storage, %expected, %vg_owner, %target_owner, %base_owner, %nvme_owner, %targets, %paths);
+ my %unmapped;
for my $sid (sort keys %$derived) {
for my $wwid (keys $derived->{$sid}->{wwids}->%*) {
@@ -61,7 +63,8 @@ sub scan_luns($cfg) {
$target_owner{ $scfg->{target} } //= $sid
if defined($scfg->{target}) && PVE::Storage::san_storage_serves_images($scfg);
$base_owner{$1} //= $sid
- if ($scfg->{base} // '') =~ m/(?:^|\.)(?:dm-uuid-(?:part\d+-)?mpath|scsi)-(.+)$/;
+ if ($scfg->{base} // '') =~ m/(?:^|[.:])(?:dm-uuid-(?:part\d+-)?mpath|scsi|nvme)-(.+)$/;
+ $nvme_owner{ $scfg->{subsysnqn} } //= $sid if $scfg->{type} eq 'nvmeof';
}
my %rows;
@@ -106,6 +109,10 @@ sub scan_luns($cfg) {
$row->{'nvme-subsystem'} = $nqn;
my $nsid = file_read_firstline("/sys/block/$name/nsid");
$row->{'nvme-nsid'} = int($nsid) if defined($nsid) && $nsid =~ /^\d+$/;
+ if (my $sid = $nvme_owner{$nqn}) {
+ $row->{'paths-expected'} =
+ scalar(PVE::NVMeOF::storage_paths($cfg->{ids}->{$sid})->@*);
+ }
}
}
for my $key (qw(transport vendor model serial)) {
@@ -205,9 +212,12 @@ sub scan_luns($cfg) {
$row->{'paths-expected'},
);
}
+ my $nvme = $nvme_owner{ $row->{'nvme-subsystem'} // '' };
+ undef $nvme if $nvme && !PVE::Storage::san_storage_serves_images($cfg->{ids}->{$nvme});
my ($target) =
map { $target_owner{$_} // () } sort keys(($targets{ $row->{wwid} } // {})->%*);
- my $owner = $base_owner{ $row->{wwid} } // $vg_owner{ $row->{vgname} // '' } // $target;
+ my $owner = $base_owner{ $row->{wwid} } // $vg_owner{ $row->{vgname} // '' } // $target
+ // $nvme;
$row->{'used-by-storage'} = $owner if defined($owner);
}
return [map { $rows{$_} } sort keys %rows];
diff --git a/src/test/run_san_lun_scan_tests.pl b/src/test/run_san_lun_scan_tests.pl
index a98e2563..06db1202 100755
--- a/src/test/run_san_lun_scan_tests.pl
+++ b/src/test/run_san_lun_scan_tests.pl
@@ -304,6 +304,12 @@ is($rows->[0]->{devpath}, '/dev/sdc', 'the row names the path that its by-id lin
$disks = { nvme0n1 => { devpath => '/dev/nvme0n1', size => 100, transport => 'nvme-fc' } };
$scan->mock(file_read_firstline => sub { $_[0] =~ m{/nsid$} ? 1 : 'eui.0123456789abcdef' });
$disk->mock(read_subsysnqn => sub { 'nqn.test' });
+$cfg->{ids}->{fabric} = {
+ type => 'nvmeof',
+ subsysnqn => 'nqn.test',
+ portals => '192.0.2.1,192.0.2.2',
+ content => { images => 1 },
+};
$scan->unmock('stable_path');
$scan->mock(abs_path => sub { '/dev/nvme0n1' });
$rows = PVE::Storage::SAN::scan_luns($cfg);
@@ -321,6 +327,28 @@ eval { PVE::JSONSchema::validate($rows, $schema) };
is($@, '', 'native row matches the API schema');
is($rows->[0]->{'nvme-subsystem'}, 'nqn.test', 'subsystem NQN exposed');
is($rows->[0]->{'nvme-nsid'}, 1, 'namespace ID exposed');
+is($rows->[0]->{'used-by-storage'}, 'fabric', 'a storage serving the namespaces uses them');
+is($rows->[0]->{'paths-expected'}, 2, 'one expected path per configured portal');
+
+for my $count (1, 3) {
+ $config->mock(
+ read_config => sub { {
+ ids => { 'eui.0123456789abcdef' => { type => 'wwid', 'paths-expected' => $count } },
+ } },
+ );
+ my $entry = PVE::Storage::SAN::scan_luns($cfg);
+ is($entry->[0]->{'paths-expected'}, 2, "a multipath entry does not change it ($count)");
+}
+$config->mock(read_config => sub { { ids => { '3600map' => { type => 'wwid' } } } });
+{
+ local $cfg->{ids}->{fabric}->{content} = { none => 1 };
+ my $plain = PVE::Storage::SAN::scan_luns($cfg);
+ is($plain->[0]->{'used-by-storage'}, undef, 'a connection storage does not');
+ is($plain->[0]->{'paths-expected'}, 2, 'but still tells the expected paths');
+}
+$cfg->{ids}->{data}->{base} = 'fabric:nvme-eui.0123456789abcdef';
+$rows = PVE::Storage::SAN::scan_luns($cfg);
+is($rows->[0]->{'used-by-storage'}, 'data', 'LVM base consumer takes precedence');
$disk->mock(is_partition => sub { 1 });
ok(!PVE::Storage::SAN::is_san_device('/dev/sdb1'), 'a partition is never a LUN');
next prev parent reply other threads:[~2026-11-18 20:43 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-18 20:42 [PATCH v2 storage,docs,manager 00/17] NVMe over Fabrics storage Thomas Lamprecht
2026-11-18 20:42 ` [PATCH v2 storage 01/17] diskmanage: skip SMART queries for NVMe fabric namespaces Thomas Lamprecht
2026-11-18 20:42 ` [PATCH v2 storage 02/17] nvmeof: add a storage for NVMe over Fabrics subsystems Thomas Lamprecht
2026-11-18 20:42 ` [PATCH v2 storage 03/17] lvm: allow a volume group on an NVMe over Fabrics namespace Thomas Lamprecht
2026-11-18 20:42 ` [PATCH v2 storage 04/17] api: scan: add NVMe over Fabrics discovery Thomas Lamprecht
2026-11-18 20:42 ` [PATCH v2 storage 05/17] pvesm: add a scan command for NVMe over Fabrics Thomas Lamprecht
2026-11-18 20:42 ` Thomas Lamprecht [this message]
2026-11-18 20:42 ` [PATCH v2 storage 07/17] api: add node-level NVMe over Fabrics status and controller removal Thomas Lamprecht
2026-11-18 20:42 ` [PATCH v2 storage 08/17] multipath: report the NVMe host NQN of each node Thomas Lamprecht
2026-11-18 20:42 ` [PATCH v2 storage 09/17] multipath: report NVMe over Fabrics namespaces in the cluster status Thomas Lamprecht
2026-11-18 20:42 ` [PATCH v2 docs 10/17] storage: document NVMe over Fabrics storages Thomas Lamprecht
2026-11-18 20:42 ` [PATCH v2 manager 11/17] api: nodes: mount the NVMe over Fabrics endpoints Thomas Lamprecht
2026-11-18 20:42 ` [PATCH v2 manager 12/17] ui: storage: add NVMe over Fabrics storage Thomas Lamprecht
2026-11-18 20:42 ` [PATCH v2 manager 13/17] ui: lvm: offer NVMe over Fabrics storages as base storage Thomas Lamprecht
2026-11-18 20:42 ` [PATCH v2 manager 14/17] ui: dc: san: add a guided setup for shared LVM on NVMe over Fabrics Thomas Lamprecht
2026-11-18 20:42 ` [PATCH v2 manager 15/17] ui: node: san: list NVMe over Fabrics controllers Thomas Lamprecht
2026-11-18 20:42 ` [PATCH v2 manager 16/17] ui: dc: san: show the NVMe host NQN of each node Thomas Lamprecht
2026-11-18 20:42 ` [PATCH v2 manager 17/17] ui: dc: san: show that a namespace uses native multipath Thomas Lamprecht
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261118204302.3100813-7-t.lamprecht@proxmox.com \
--to=t.lamprecht@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox