From: Thomas Lamprecht <t.lamprecht@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH storage 06/17] api: scan: san-luns: attribute NVMe namespaces to storage
Date: Fri, 13 Nov 2026 04:04:34 +0100 [thread overview]
Message-ID: <20261113030541.1591528-7-t.lamprecht@proxmox.com> (raw)
In-Reply-To: <20261113030541.1591528-1-t.lamprecht@proxmox.com>
The SAN LUN inventory lists NVMe namespaces without relation to an
NVMe over Fabrics storage. Report the subsystem NQN and the namespace
ID of a namespace, and expect one path per portal of the storage that
connects its subsystem, 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 | 10 +++++++++
src/PVE/Storage/SAN.pm | 25 ++++++++++++++++++----
src/test/run_san_lun_scan_tests.pl | 33 +++++++++++++++++++++++++++++-
3 files changed, 63 insertions(+), 5 deletions(-)
diff --git a/src/PVE/API2/Storage/Scan.pm b/src/PVE/API2/Storage/Scan.pm
index a9d05f79..35c1c71f 100644
--- a/src/PVE/API2/Storage/Scan.pm
+++ b/src/PVE/API2/Storage/Scan.pm
@@ -596,6 +596,16 @@ __PACKAGE__->register_method({
type => 'string',
optional => 1,
},
+ 'nvme-subsystem' => {
+ description => 'The NVMe subsystem NQN.',
+ type => 'string',
+ optional => 1,
+ },
+ 'nvme-nsid' => {
+ description => 'The namespace ID within the NVMe subsystem.',
+ type => 'integer',
+ optional => 1,
+ },
'iscsi-target' => {
description => "The IQN of the iSCSI target the LUN is attached through.",
type => 'string',
diff --git a/src/PVE/Storage/SAN.pm b/src/PVE/Storage/SAN.pm
index f3682106..b281177b 100644
--- a/src/PVE/Storage/SAN.pm
+++ b/src/PVE/Storage/SAN.pm
@@ -15,6 +15,7 @@ use PVE::Multipath;
use PVE::Multipath::Generator;
use PVE::Multipath::Config;
use PVE::Multipath::Identity;
+use PVE::NVMeOF;
use PVE::Storage;
use PVE::Storage::LVMPlugin;
use PVE::Tools qw(file_read_firstline dir_glob_foreach run_command);
@@ -34,7 +35,7 @@ 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);
+ my (%storage, %expected, %vg_owner, %target_owner, %base_owner, %nvme_owner);
for my $sid (sort keys %$derived) {
for my $wwid (keys $derived->{$sid}->{wwids}->%*) {
@@ -52,7 +53,9 @@ sub scan_luns($cfg) {
$vg_owner{ $scfg->{vgname} } //= $sid if defined($scfg->{vgname});
$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-mpath-(.+)$/;
+ $base_owner{$1} //= $sid
+ if ($scfg->{base} // '') =~ m/(?:^|[.:])(?:dm-uuid-mpath|nvme)-(.+)$/;
+ $nvme_owner{ $scfg->{subsysnqn} } //= $sid if $scfg->{type} eq 'nvmeof';
}
my %rows;
@@ -96,7 +99,19 @@ sub scan_luns($cfg) {
: $storage{$wwid} ? 'storage'
: 'unmanaged';
}
- $row->{multipath} = 'native' if $name =~ /^nvme\d+n\d+$/;
+ if ($name =~ /^nvme\d+n\d+$/) {
+ $row->{multipath} = 'native';
+ my $nqn = PVE::Diskmanage::read_subsysnqn("/sys/block/$name/device/subsysnqn");
+ if (defined($nqn)) {
+ $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)) {
my $value = $disk->{$key};
$row->{$key} //= $value if defined($value) && $value ne 'unknown';
@@ -150,8 +165,10 @@ 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 $owner = $base_owner{ $row->{wwid} } // $vg_owner{ $row->{vgname} // '' }
- // $target_owner{ $row->{'iscsi-target'} // '' };
+ // $target_owner{ $row->{'iscsi-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 94df0d5c..3578a3af 100755
--- a/src/test/run_san_lun_scan_tests.pl
+++ b/src/test/run_san_lun_scan_tests.pl
@@ -165,7 +165,14 @@ is($rows->[0]->{'by-id'}, '/dev/disk/by-id/scsi-3600plain', 'by-id link of the s
is($rows->[0]->{devpath}, '/dev/sdc', 'the row names the path that its by-id link resolves to');
$disks = { nvme0n1 => { devpath => '/dev/nvme0n1', size => 100, transport => 'nvme-fc' } };
-$scan->mock(file_read_firstline => sub { 'eui.0123456789abcdef' });
+$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',
+ 'nvme-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);
@@ -173,6 +180,30 @@ is($rows->[0]->{multipath}, 'native', 'NVMe uses kernel-native multipath');
is($rows->[0]->{'by-id'}, '/dev/disk/by-id/nvme-eui.0123456789abcdef', 'NVMe stable name');
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-13 3:28 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-13 3:04 [PATCH storage,docs,manager 00/17] NVMe over Fabrics storage Thomas Lamprecht
2026-11-13 3:04 ` [PATCH storage 01/17] diskmanage: skip SMART queries for NVMe fabric namespaces Thomas Lamprecht
2026-11-13 3:04 ` [PATCH storage 02/17] nvmeof: add a storage for NVMe over Fabrics subsystems Thomas Lamprecht
2026-11-13 3:04 ` [PATCH storage 03/17] lvm: allow a volume group on an NVMe over Fabrics namespace Thomas Lamprecht
2026-11-13 3:04 ` [PATCH storage 04/17] api: scan: add NVMe over Fabrics discovery Thomas Lamprecht
2026-11-13 3:04 ` [PATCH storage 05/17] pvesm: add a scan command for NVMe over Fabrics Thomas Lamprecht
2026-11-13 3:04 ` Thomas Lamprecht [this message]
2026-11-13 3:04 ` [PATCH storage 07/17] api: add node-level NVMe over Fabrics status and controller removal Thomas Lamprecht
2026-11-13 3:04 ` [PATCH storage 08/17] multipath: report the NVMe host NQN of each node Thomas Lamprecht
2026-11-13 3:04 ` [PATCH storage 09/17] multipath: report NVMe over Fabrics namespaces in the cluster status Thomas Lamprecht
2026-11-13 3:04 ` [PATCH docs 10/17] storage: document NVMe over Fabrics storages Thomas Lamprecht
2026-11-13 3:04 ` [PATCH manager 11/17] api: nodes: mount the NVMe over Fabrics endpoints Thomas Lamprecht
2026-11-13 3:04 ` [PATCH manager 12/17] ui: storage: add NVMe over Fabrics storage Thomas Lamprecht
2026-11-13 3:04 ` [PATCH manager 13/17] ui: lvm: offer NVMe over Fabrics storages as base storage Thomas Lamprecht
2026-11-13 3:04 ` [PATCH manager 14/17] ui: dc: san: add a guided setup for shared LVM on NVMe over Fabrics Thomas Lamprecht
2026-11-13 3:04 ` [PATCH manager 15/17] ui: node: san: list NVMe over Fabrics controllers Thomas Lamprecht
2026-11-13 3:04 ` [PATCH manager 16/17] ui: dc: san: show the NVMe host NQN of each node Thomas Lamprecht
2026-11-13 3:04 ` [PATCH manager 17/17] ui: dc: san: show that a namespace uses native multipath Thomas Lamprecht
2026-11-18 20:44 ` superseded: [PATCH storage,docs,manager 00/17] NVMe over Fabrics storage 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=20261113030541.1591528-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