all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Thomas Lamprecht <t.lamprecht@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH v5 storage 11/26] api: san luns: attribute NVMe namespaces to storage
Date: Mon, 23 Nov 2026 14:32:03 +0100	[thread overview]
Message-ID: <20261123133412.3710030-12-t.lamprecht@proxmox.com> (raw)
In-Reply-To: <20261123133412.3710030-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/SAN/Node.pm           |  9 ++++---
 src/PVE/Storage/SAN.pm             | 19 ++++++++++++--
 src/test/run_san_lun_scan_tests.pl | 41 ++++++++++++++++++++++++++++++
 3 files changed, 63 insertions(+), 6 deletions(-)

diff --git a/src/PVE/API2/SAN/Node.pm b/src/PVE/API2/SAN/Node.pm
index 08a7473b..4b96caf5 100644
--- a/src/PVE/API2/SAN/Node.pm
+++ b/src/PVE/API2/SAN/Node.pm
@@ -118,8 +118,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,
                 },
@@ -198,8 +199,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 595c3b55..5e7065fc 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,9 @@ 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, %nvme_paths);
+    my (%targets, %paths);
+    my %unmapped;
 
     my $wanted =
         PVE::Multipath::Generator::wanted_wwids($mpcfg, PVE::INotify::nodename(), $derived);
@@ -58,6 +61,11 @@ sub scan_luns($cfg) {
             if defined($scfg->{target}) && PVE::Storage::san_storage_serves_images($scfg);
         my $base = PVE::Multipath::parse_base_volume($scfg->{base});
         $base_owner{ $base->{wwid} } //= $sid if $base;
+        next if $scfg->{type} ne 'nvmeof';
+        $nvme_owner{ $scfg->{subsysnqn} } //= $sid;
+        # only a storage in use on this node expects its paths here
+        $nvme_paths{ $scfg->{subsysnqn} } //= $sid
+            if PVE::Storage::storage_check_enabled($cfg, $sid, undef, 1);
     }
 
     my %rows;
@@ -102,6 +110,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_paths{$nqn}) {
+                    $row->{'paths-expected'} =
+                        scalar(PVE::NVMeOF::storage_paths($cfg->{ids}->{$sid})->@*);
+                }
             }
         }
         for my $key (qw(transport vendor model serial)) {
@@ -208,9 +220,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 7119c88a..7fd9563b 100755
--- a/src/test/run_san_lun_scan_tests.pl
+++ b/src/test/run_san_lun_scan_tests.pl
@@ -329,6 +329,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);
@@ -346,6 +352,41 @@ 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');
+}
+{
+    local $cfg->{ids}->{fabric}->{disable} = 1;
+    my $disabled = PVE::Storage::SAN::scan_luns($cfg);
+    is($disabled->[0]->{'paths-expected'}, undef, 'a disabled storage expects no paths');
+    is($disabled->[0]->{'used-by-storage'}, 'fabric', 'but still uses the namespaces');
+}
+{
+    local $cfg->{ids}->{fabric}->{nodes} = { other => 1 };
+    my $elsewhere = PVE::Storage::SAN::scan_luns($cfg);
+    is($elsewhere->[0]->{'paths-expected'}, undef, 'nor a storage of other nodes');
+}
+for my $base (qw(fabric nvme-fabric)) {
+    $cfg->{ids}->{data}->{base} = "$base:nvme-eui.0123456789abcdef";
+    $rows = PVE::Storage::SAN::scan_luns($cfg);
+    is($rows->[0]->{'used-by-storage'}, 'data', "LVM base consumer takes precedence ($base)");
+}
 
 $disk->mock(is_partition => sub { 1 });
 ok(!PVE::Storage::SAN::is_san_device('/dev/sdb1'), 'a partition is never a LUN');




  parent reply	other threads:[~2026-11-23 13:37 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-23 13:31 applied: [PATCH v5 storage,docs,manager 00/26] NVMe over Fabrics storage Thomas Lamprecht
2026-11-23 13:31 ` [PATCH v5 storage 01/26] api: config: activate a new storage without holding the lock Thomas Lamprecht
2026-11-23 13:31 ` [PATCH v5 storage 02/26] diskmanage: skip SMART queries for NVMe fabric namespaces Thomas Lamprecht
2026-11-23 13:31 ` [PATCH v5 storage 03/26] diskmanage: list NVMe namespaces attached over TCP or RDMA for SAN only Thomas Lamprecht
2026-11-23 13:31 ` [PATCH v5 storage 04/26] api: disks: refuse a local wipe of a network NVMe namespace Thomas Lamprecht
2026-11-23 13:31 ` [PATCH v5 storage 05/26] nvmeof: add a storage for NVMe over Fabrics subsystems Thomas Lamprecht
2026-11-23 13:31 ` [PATCH v5 storage 06/26] d/control: bump pve-common for plain parameter error names Thomas Lamprecht
2026-11-23 13:31 ` [PATCH v5 storage 07/26] api: config: check the cluster version before the first nvmeof storage Thomas Lamprecht
2026-11-23 13:32 ` [PATCH v5 storage 08/26] lvm: allow a volume group on an NVMe over Fabrics namespace Thomas Lamprecht
2026-11-23 13:32 ` [PATCH v5 storage 09/26] api: scan: add NVMe over Fabrics discovery Thomas Lamprecht
2026-11-23 13:32 ` [PATCH v5 storage 10/26] pvesm: add a scan command for NVMe over Fabrics Thomas Lamprecht
2026-11-23 13:32 ` Thomas Lamprecht [this message]
2026-11-23 13:32 ` [PATCH v5 storage 12/26] api: add node-level NVMe over Fabrics status and controller removal Thomas Lamprecht
2026-11-23 13:32 ` [PATCH v5 storage 13/26] multipath: report the NVMe host NQN of each node Thomas Lamprecht
2026-11-23 13:32 ` [PATCH v5 storage 14/26] multipath: report NVMe over Fabrics namespaces in the cluster status Thomas Lamprecht
2026-11-23 13:32 ` [PATCH v5 storage 15/26] d/control: break pve-manager versions without namespace notifications Thomas Lamprecht
2026-11-23 13:32 ` [PATCH v5 docs 16/26] storage: document NVMe over Fabrics storages Thomas Lamprecht
2026-11-23 13:32 ` [PATCH v5 manager 17/26] report: add the NVMe over Fabrics host NQN and subsystems Thomas Lamprecht
2026-11-23 13:32 ` [PATCH v5 manager 18/26] ui: storage: add NVMe over Fabrics storage Thomas Lamprecht
2026-11-23 13:32 ` [PATCH v5 manager 19/26] ui: lvm: offer NVMe over Fabrics storages as base storage Thomas Lamprecht
2026-11-23 13:32 ` [PATCH v5 manager 20/26] ui: storage: SAN setup: ignore spaces around a typed portal Thomas Lamprecht
2026-11-23 13:32 ` [PATCH v5 manager 21/26] ui: storage: add a guided setup for shared LVM on NVMe over Fabrics Thomas Lamprecht
2026-11-23 13:32 ` [PATCH v5 manager 22/26] ui: node san: list NVMe over Fabrics controllers Thomas Lamprecht
2026-11-23 13:32 ` [PATCH v5 manager 23/26] ui: san: show the NVMe host NQN of each node Thomas Lamprecht
2026-11-23 13:32 ` [PATCH v5 manager 24/26] ui: san: show that a namespace uses native multipath Thomas Lamprecht
2026-11-23 13:32 ` [PATCH v5 manager 25/26] pvestatd: notify on NVMe over Fabrics namespaces as on multipath maps Thomas Lamprecht
2026-11-23 13:32 ` [PATCH v5 manager 26/26] d/control: bump versioned dependencies for NVMe over Fabrics 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=20261123133412.3710030-12-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal