From: Thomas Lamprecht <t.lamprecht@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH v4 storage 02/25] diskmanage: list NVMe namespaces attached over TCP or RDMA for SAN only
Date: Mon, 23 Nov 2026 02:47:39 +0100 [thread overview]
Message-ID: <20261123020041.3728085-3-t.lamprecht@proxmox.com> (raw)
In-Reply-To: <20261123020041.3728085-1-t.lamprecht@proxmox.com>
The disk list for local disk setup leaves out iSCSI LUNs, which storages
connect for use on several nodes. Namespaces attached over TCP or RDMA
are the same kind of device, but were listed, so Node > Disks offered
them for a ZFS pool, a directory, a volume group or a Ceph OSD, while
other nodes could use the same namespace.
Leave them out unless the SAN inventory asks for them, so the SAN views
still show them, and also a namespace whose transport cannot be read,
like one whose last controller is gone. For a subsystem with controllers
of several transports, a fabric one counts, whatever their order. The
partitions go with their namespace, so the checks before local disk
setup refuse both as not a valid local disk, and removing a directory or
ZFS pool on one with the cleanup of its disks refuses as for an iSCSI
LUN. Namespaces attached over Fibre Channel stay listed, as Fibre
Channel LUNs do, since a volume group created under Node > Disks is how
these get a shared LVM storage.
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---
src/PVE/Diskmanage.pm | 30 ++++--
.../multipath/disklist_expected.json | 16 ----
.../nvme_smart/nvme0n1/device/transport | 1 +
src/test/disklist_test.pm | 94 +++++++++++++++++--
4 files changed, 109 insertions(+), 32 deletions(-)
create mode 100644 src/test/disk_tests/nvme_smart/nvme0n1/device/transport
diff --git a/src/PVE/Diskmanage.pm b/src/PVE/Diskmanage.pm
index be3fb8fc..eb97eab7 100644
--- a/src/PVE/Diskmanage.pm
+++ b/src/PVE/Diskmanage.pm
@@ -555,23 +555,27 @@ sub read_subsysnqn {
}
# Returns the NVMe transport (pcie, fc, tcp, rdma, loop) of a namespace, either directly from
-# its controller, or from any controller of its subsystem for native NVMe multipath setups.
+# its controller, or from the controllers of its subsystem for native NVMe multipath setups. Of
+# several transports, one over a fabric wins, independent of the order of the controllers.
sub get_nvme_transport {
my ($sysdir) = @_;
my $transport = file_read_firstline("$sysdir/device/transport");
return $transport if defined($transport);
+ my $found = {};
dir_glob_foreach(
"$sysdir/device",
'nvme\d+',
sub {
my ($controller) = @_;
- $transport //= file_read_firstline("$sysdir/device/$controller/transport");
+ my $value = file_read_firstline("$sysdir/device/$controller/transport");
+ $found->{$value} = 1 if defined($value);
},
);
- return $transport;
+ my ($first) = grep { $found->{$_} } (qw(tcp rdma fc), sort keys $found->%*);
+ return $first;
}
# SAS does not distinguish local from remote attachments, so it is not classified as remote.
@@ -614,7 +618,10 @@ sub mounted_paths {
sub get_disks {
my ($disks, $nosmart, $include_partitions, $san_inventory) = @_;
- # SAN inventory includes iSCSI session devices and skips usage probes that read devices.
+ # Only the SAN inventory includes iSCSI LUNs and NVMe namespaces attached over TCP or RDMA, or
+ # over an unknown transport, as storages connect them for use on several nodes. Fibre Channel
+ # devices stay listed, as local disk setup is how a volume group gets onto one. The SAN
+ # inventory skips usage probes that read devices.
my $disklist = {};
my $mounted = mounted_blockdevs();
@@ -679,15 +686,20 @@ sub get_disks {
return if !$san_inventory && is_iscsi_device($dev);
+ my $sysdir = "/sys/block/$dev";
+
+ my $nvme_transport;
+ if ($dev =~ m/^nvme/) {
+ $nvme_transport = get_nvme_transport($sysdir);
+ # like a namespace whose last controller is gone, which can be one over a network
+ return if !$san_inventory && !defined($nvme_transport);
+ }
+ return if !$san_inventory && ($nvme_transport // '') =~ /^(?:tcp|rdma)$/;
+
$udev_db //= get_udev_db() if ++$udev_queries > $udev_single;
my $data = get_udev_info("/sys/block/$dev", $udev_db) // return;
my $devpath = $data->{devpath};
- my $sysdir = "/sys/block/$dev";
-
- my $nvme_transport;
- $nvme_transport = get_nvme_transport($sysdir) if $dev =~ m/^nvme/;
-
my $sysdata = get_sysdir_info($sysdir);
return if !defined($sysdata);
diff --git a/src/test/disk_tests/multipath/disklist_expected.json b/src/test/disk_tests/multipath/disklist_expected.json
index ec442969..8098dd8d 100644
--- a/src/test/disk_tests/multipath/disklist_expected.json
+++ b/src/test/disk_tests/multipath/disklist_expected.json
@@ -87,21 +87,5 @@
"osdid-list": null,
"by_id_link": "/dev/disk/by-id/nvme-FCMODEL_FCNVME1",
"transport": "nvme-fc"
- },
- "nvme9n1": {
- "devpath": "/dev/nvme9n1",
- "size": 10737418240,
- "vendor": "FABVEND",
- "model": "FABRICS CTRL",
- "serial": "FAB1",
- "wwn": "uuid.10000000-0000-0000-0000-000000000001",
- "gpt": 0,
- "rpm": 0,
- "type": "nvme",
- "health": "UNKNOWN",
- "wearout": "N/A",
- "osdid": -1,
- "osdid-list": null,
- "transport": "nvme-tcp"
}
}
diff --git a/src/test/disk_tests/nvme_smart/nvme0n1/device/transport b/src/test/disk_tests/nvme_smart/nvme0n1/device/transport
new file mode 100644
index 00000000..30e0ba74
--- /dev/null
+++ b/src/test/disk_tests/nvme_smart/nvme0n1/device/transport
@@ -0,0 +1 @@
+pcie
diff --git a/src/test/disklist_test.pm b/src/test/disklist_test.pm
index 38823f8b..fae8ce45 100644
--- a/src/test/disklist_test.pm
+++ b/src/test/disklist_test.pm
@@ -290,12 +290,63 @@ sub test_disk_list {
for my $transport (qw(tcp rdma fc pcie)) {
$smart_calls = 0;
$diskmanage_module->mock(get_nvme_transport => sub { $transport });
- PVE::Diskmanage::get_disks();
+ # with SMART, as the SAN inventory lists the namespaces of all transports
+ PVE::Diskmanage::get_disks(undef, 0, 0, 1);
$testcount++;
is($smart_calls, $transport eq 'pcie' ? 1 : 0, "SMART queries for $transport");
}
$diskmanage_module->unmock('get_smart_data');
- $diskmanage_module->unmock('get_nvme_transport');
+
+ for my $transport ('tcp', 'rdma', 'fc', 'pcie', undef) {
+ $diskmanage_module->mock(get_nvme_transport => sub { $transport });
+ my $local = ($transport // '') =~ /^(?:fc|pcie)$/;
+ my $name = $transport // 'an unknown transport';
+ $testcount += 3;
+ is(
+ !!PVE::Diskmanage::get_disks()->{nvme0n1},
+ $local,
+ "disk list for local setup with $name",
+ );
+ ok(
+ PVE::Diskmanage::get_disks(undef, 1, 0, 1)->{nvme0n1},
+ "SAN inventory with $name",
+ );
+ eval { PVE::Diskmanage::assert_disk_unused('/dev/nvme0n1') };
+ like(
+ $@,
+ $local ? qr/^$/ : qr/not a valid local disk/,
+ "local disk setup with $name",
+ );
+ }
+
+ $diskmanage_module->mock(
+ dir_glob_foreach => sub {
+ my ($dir, $regex, $sub) = @_;
+ return $sub->('nvme0n1p1') if $dir eq '/sys/block/nvme0n1';
+ return mocked_dir_glob_foreach(@_);
+ },
+ is_partition => sub { return $_[0] eq '/dev/nvme0n1p1' },
+ get_blockdev => sub { return '/dev/nvme0n1' },
+ );
+ for my $transport (qw(tcp rdma fc pcie)) {
+ $diskmanage_module->mock(get_nvme_transport => sub { $transport });
+ my $local = $transport eq 'fc' || $transport eq 'pcie';
+ $testcount += 2;
+ is(
+ !!PVE::Diskmanage::get_disks(undef, 1, 1)->{nvme0n1p1},
+ $local,
+ "partition list for local setup with $transport",
+ );
+ # partitions have holders in these tests, so a listed one counts as used
+ eval { PVE::Diskmanage::assert_disk_unused('/dev/nvme0n1p1') };
+ like(
+ $@,
+ $local ? qr/already in use/ : qr/not a valid local disk/,
+ "local disk setup on a partition with $transport",
+ );
+ }
+ $diskmanage_module->mock(dir_glob_foreach => \&mocked_dir_glob_foreach);
+ $diskmanage_module->unmock($_) for qw(is_partition get_blockdev get_nvme_transport);
}
if (-f "disk_tests/$testcasedir/multipathd_status_expected.json") {
@@ -342,7 +393,8 @@ sub test_disk_list {
$udev_single_queries = 0;
my $listed = PVE::Diskmanage::get_disks();
$testcount++;
- is(scalar(keys %$listed), 6, 'all disks listed');
+ is(scalar(keys %$listed), 5,
+ 'all disks listed but the namespace attached over TCP');
$testcount++;
is(
$udev_single_queries,
@@ -350,8 +402,8 @@ sub test_disk_list {
'the database replaces the queries after the first disks',
);
- # six disks: 240 block devices are just enough to ask about each of them on its own
- for my $count (240, 239) {
+ # five disks: 200 block devices are just enough to ask about each of them on its own
+ for my $count (200, 199) {
$diskmanage_module->mock(
get_lsblk_info => sub {
return { map { ("/dev/dm-$_" => {}) } 1 .. $count };
@@ -363,10 +415,38 @@ sub test_disk_list {
$testcount++;
is(
$udev_single_queries,
- $count == 240 ? 6 : 5,
- "single queries for six disks among $count block devices",
+ $count == 200 ? 5 : 4,
+ "single queries for five disks among $count block devices",
);
}
+
+ my $san = PVE::Diskmanage::get_disks(undef, 1, 0, 1);
+ $testcount++;
+ is($san->{nvme9n1}->{transport}, 'nvme-tcp', 'SAN inventory lists it');
+
+ # a second controller of the subsystem over Fibre Channel, listed before or after
+ for my $order ([qw(nvme4 nvme5)], [qw(nvme5 nvme4)]) {
+ $diskmanage_module->mock(
+ dir_glob_foreach => sub {
+ my ($dir, $regex, $sub) = @_;
+ return mocked_dir_glob_foreach(@_)
+ if $dir ne '/sys/block/nvme9n1/device';
+ $sub->($_) for $order->@*;
+ },
+ file_read_firstline => sub {
+ return 'fc' if $_[0] eq '/sys/block/nvme9n1/device/nvme4/transport';
+ return mocked_file_read_firstline(@_);
+ },
+ );
+ $testcount++;
+ is(
+ PVE::Diskmanage::get_nvme_transport('/sys/block/nvme9n1'),
+ 'tcp',
+ "TCP wins over Fibre Channel listed as $order->[0], $order->[1]",
+ );
+ }
+ $diskmanage_module->mock(dir_glob_foreach => \&mocked_dir_glob_foreach);
+ $diskmanage_module->mock(file_read_firstline => \&mocked_file_read_firstline);
}
done_testing($testcount);
next prev parent reply other threads:[~2026-11-23 2:02 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-23 1:47 [PATCH v4 storage,docs,manager 00/25] NVMe over Fabrics storage Thomas Lamprecht
2026-11-23 1:47 ` [PATCH v4 storage 01/25] diskmanage: skip SMART queries for NVMe fabric namespaces Thomas Lamprecht
2026-11-23 1:47 ` Thomas Lamprecht [this message]
2026-11-23 1:47 ` [PATCH v4 storage 03/25] api: disks: refuse a local wipe of a network NVMe namespace Thomas Lamprecht
2026-11-23 1:47 ` [PATCH v4 storage 04/25] nvmeof: add a storage for NVMe over Fabrics subsystems Thomas Lamprecht
2026-11-23 1:47 ` [PATCH v4 storage 05/25] d/control: bump pve-common for plain parameter error names Thomas Lamprecht
2026-11-23 1:47 ` [PATCH v4 storage 06/25] api: config: check the cluster version before the first nvmeof storage Thomas Lamprecht
2026-11-23 1:47 ` [PATCH v4 storage 07/25] lvm: allow a volume group on an NVMe over Fabrics namespace Thomas Lamprecht
2026-11-23 1:47 ` [PATCH v4 storage 08/25] api: scan: add NVMe over Fabrics discovery Thomas Lamprecht
2026-11-23 1:47 ` [PATCH v4 storage 09/25] pvesm: add a scan command for NVMe over Fabrics Thomas Lamprecht
2026-11-23 1:47 ` [PATCH v4 storage 10/25] api: san luns: attribute NVMe namespaces to storage Thomas Lamprecht
2026-11-23 1:47 ` [PATCH v4 storage 11/25] api: add node-level NVMe over Fabrics status and controller removal Thomas Lamprecht
2026-11-23 1:47 ` [PATCH v4 storage 12/25] multipath: report the NVMe host NQN of each node Thomas Lamprecht
2026-11-23 1:47 ` [PATCH v4 storage 13/25] multipath: report NVMe over Fabrics namespaces in the cluster status Thomas Lamprecht
2026-11-23 1:47 ` [PATCH v4 storage 14/25] d/control: break pve-manager versions without namespace notifications Thomas Lamprecht
2026-11-23 1:47 ` [PATCH v4 docs 15/25] storage: document NVMe over Fabrics storages Thomas Lamprecht
2026-11-23 1:47 ` [PATCH v4 manager 16/25] report: add the NVMe over Fabrics host NQN and subsystems Thomas Lamprecht
2026-11-23 1:47 ` [PATCH v4 manager 17/25] ui: storage: add NVMe over Fabrics storage Thomas Lamprecht
2026-11-23 1:47 ` [PATCH v4 manager 18/25] ui: lvm: offer NVMe over Fabrics storages as base storage Thomas Lamprecht
2026-11-23 1:47 ` [PATCH v4 manager 19/25] ui: storage: add a guided setup for shared LVM on NVMe over Fabrics Thomas Lamprecht
2026-11-23 1:47 ` [PATCH v4 manager 20/25] ui: node san: list NVMe over Fabrics controllers Thomas Lamprecht
2026-11-23 1:47 ` [PATCH v4 manager 21/25] ui: san: show the NVMe host NQN of each node Thomas Lamprecht
2026-11-23 1:47 ` [PATCH v4 manager 22/25] ui: san: show that a namespace uses native multipath Thomas Lamprecht
2026-11-23 1:48 ` [PATCH v4 manager 23/25] pvestatd: notify on NVMe over Fabrics namespaces as on multipath maps Thomas Lamprecht
2026-11-23 1:48 ` [PATCH v4 manager 24/25] ui: storage: SAN setup: ignore spaces around a typed portal Thomas Lamprecht
2026-11-23 1:48 ` [PATCH v4 manager 25/25] d/control: bump versioned dependencies for NVMe over Fabrics Thomas Lamprecht
2026-11-23 13:35 ` superseded: [PATCH v4 storage,docs,manager 00/25] 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=20261123020041.3728085-3-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.