From: Joaquin Varela <joaquinvarela@neatech.ar>
To: pve-devel@lists.proxmox.com
Subject: [PATCH storage v5 05/13] api: san luns: count zfsnvme storages as owners of their subsystem
Date: Thu, 26 Nov 2026 12:09:46 -0300 [thread overview]
Message-ID: <20261126150956.310593-6-joaquinvarela@neatech.ar> (raw)
In-Reply-To: <20261126150956.310593-1-joaquinvarela@neatech.ar>
A zfsnvme storage owns the subsystem it exports, like an nvmeof storage
does. Count it as the owner in the SAN LUN list, in the unreferenced
check behind wiping and disconnecting, in the controller list and in the
check for one storage per subsystem. Otherwise its namespaces show up as
owned by nobody and a second storage could take its subsystem.
Add PVE::NVMeOF::storage_subsystem() for the match and let the
used-by-storage descriptions name both types. Expected paths stay with
nvmeof, as they come from the portals option and zfsnvme lists its
portals in nvme-portals with its own syntax. The cluster multipath
status keeps listing only nvmeof namespaces.
Signed-off-by: Joaquin Varela <joaquinvarela@neatech.ar>
---
src/PVE/API2/NVMeOF.pm | 7 ++++---
src/PVE/API2/SAN/Cluster.pm | 6 +++---
src/PVE/API2/SAN/Node.pm | 5 +++--
src/PVE/NVMeOF.pm | 6 ++++++
src/PVE/Storage/NVMeOFPlugin.pm | 4 ++--
src/PVE/Storage/SAN.pm | 16 ++++++++--------
src/test/run_nvmeof_api_tests.pl | 16 ++++++++++++++--
src/test/run_nvmeof_tests.pl | 12 ++++++++++++
src/test/run_san_lun_scan_tests.pl | 11 +++++++++++
src/test/run_san_nvme_tests.pl | 4 ++++
10 files changed, 67 insertions(+), 20 deletions(-)
diff --git a/src/PVE/API2/NVMeOF.pm b/src/PVE/API2/NVMeOF.pm
index 9205d084..eecb242a 100644
--- a/src/PVE/API2/NVMeOF.pm
+++ b/src/PVE/API2/NVMeOF.pm
@@ -119,7 +119,8 @@ __PACKAGE__->register_method({
'used-by-storage' => {
type => 'string',
optional => 1,
- description => 'An NVMe over Fabrics storage using the subsystem.',
+ description =>
+ 'An NVMe over Fabrics or ZFS over NVMe/TCP storage using the subsystem.',
},
},
},
@@ -128,8 +129,8 @@ __PACKAGE__->register_method({
my $cfg = PVE::Storage::config();
my %owners;
for my $sid (sort keys $cfg->{ids}->%*) {
- my $scfg = $cfg->{ids}->{$sid};
- $owners{ $scfg->{subsysnqn} } //= $sid if $scfg->{type} eq 'nvmeof';
+ my $nqn = PVE::NVMeOF::storage_subsystem($cfg->{ids}->{$sid}) // next;
+ $owners{$nqn} //= $sid;
}
my $controllers = PVE::NVMeOF::controllers();
my $counts = PVE::NVMeOF::namespace_counts();
diff --git a/src/PVE/API2/SAN/Cluster.pm b/src/PVE/API2/SAN/Cluster.pm
index 7198846c..e0d3e145 100644
--- a/src/PVE/API2/SAN/Cluster.pm
+++ b/src/PVE/API2/SAN/Cluster.pm
@@ -185,9 +185,9 @@ __PACKAGE__->register_method({
optional => 1,
description =>
'The storage that uses the LUN: as its base volume or 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.',
+ . ' the volume group on it, or as an iSCSI, NVMe over Fabrics or'
+ . ' ZFS over NVMe/TCP storage that serves the LUNs of its target'
+ . ' or subsystem as images.',
},
'multipath-storage' => {
type => 'string',
diff --git a/src/PVE/API2/SAN/Node.pm b/src/PVE/API2/SAN/Node.pm
index 260c95f7..ddaf0e9b 100644
--- a/src/PVE/API2/SAN/Node.pm
+++ b/src/PVE/API2/SAN/Node.pm
@@ -205,8 +205,9 @@ __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 or NVMe over Fabrics"
- . " storage that serves the LUNs of its target or subsystem as images.",
+ . " through the volume group on it, or as an iSCSI, NVMe over Fabrics or"
+ . " ZFS over NVMe/TCP storage that serves the LUNs of its target or"
+ . " subsystem as images.",
type => 'string',
optional => 1,
},
diff --git a/src/PVE/NVMeOF.pm b/src/PVE/NVMeOF.pm
index a2091f55..5c450468 100644
--- a/src/PVE/NVMeOF.pm
+++ b/src/PVE/NVMeOF.pm
@@ -90,6 +90,12 @@ sub storage_paths($scfg) {
PVE::Tools::split_list($scfg->{portals})];
}
+# The NQN of the subsystem that a storage owns, or undef. NVMe over Fabrics and ZFS over NVMe/TCP
+# storages each own one. Only the former lists its portals in 'portals', see storage_paths.
+sub storage_subsystem($scfg) {
+ return $scfg->{type} =~ /\A(?:nvmeof|zfsnvme)\z/ ? $scfg->{subsysnqn} : undef;
+}
+
sub host_identity() {
my ($nqn) = (file_read_firstline($HOSTNQN_FILE) // '') =~ /\A($NQN_PATTERN)\z/;
my ($id) = (file_read_firstline($HOSTID_FILE) // '') =~
diff --git a/src/PVE/Storage/NVMeOFPlugin.pm b/src/PVE/Storage/NVMeOFPlugin.pm
index 05acf08b..1b8ff72d 100644
--- a/src/PVE/Storage/NVMeOFPlugin.pm
+++ b/src/PVE/Storage/NVMeOFPlugin.pm
@@ -91,9 +91,9 @@ sub on_add_hook($class, $storeid, $scfg, %param) {
# the LUN and controller lists and the node status attribute a subsystem to its one storage
my $ids = PVE::Storage::config()->{ids};
for my $sid (sort keys %$ids) {
- next if $sid eq $storeid || $ids->{$sid}->{type} ne 'nvmeof';
+ next if $sid eq $storeid;
die "storage '$sid' already uses this subsystem\n"
- if $ids->{$sid}->{subsysnqn} eq $scfg->{subsysnqn};
+ if (PVE::NVMeOF::storage_subsystem($ids->{$sid}) // '') eq $scfg->{subsysnqn};
}
PVE::NVMeOF::clear_connect_failures($scfg);
return;
diff --git a/src/PVE/Storage/SAN.pm b/src/PVE/Storage/SAN.pm
index bf363301..c9ee670b 100644
--- a/src/PVE/Storage/SAN.pm
+++ b/src/PVE/Storage/SAN.pm
@@ -60,11 +60,12 @@ 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 $nqn = PVE::NVMeOF::storage_subsystem($scfg) // next;
+ $nvme_owner{$nqn} //= $sid;
+ # only a storage in use on this node expects its paths here, and only one with 'portals'
+ $nvme_paths{$nqn} //= $sid
+ if $scfg->{type} eq 'nvmeof'
+ && PVE::Storage::storage_check_enabled($cfg, $sid, undef, 1);
}
my %rows;
@@ -343,9 +344,8 @@ sub assert_lun_unreferenced($cfg, $lun, $exempt = undef) {
die "cannot use '$lun->{devpath}' - storage '$sid' serves images from this target\n";
}
if (
- $type eq 'nvmeof'
- && defined($nqn)
- && $scfg->{subsysnqn} eq $nqn
+ defined($nqn)
+ && (PVE::NVMeOF::storage_subsystem($scfg) // '') eq $nqn
&& PVE::Storage::san_storage_serves_images($scfg)
) {
die "cannot use '$lun->{devpath}' - storage '$sid' serves images from this subsystem\n";
diff --git a/src/test/run_nvmeof_api_tests.pl b/src/test/run_nvmeof_api_tests.pl
index 888c8dba..8bffb463 100755
--- a/src/test/run_nvmeof_api_tests.pl
+++ b/src/test/run_nvmeof_api_tests.pl
@@ -212,8 +212,12 @@ subtest 'node API contract' => sub {
my $nvme = Test::MockModule->new('PVE::NVMeOF');
my $storage = Test::MockModule->new('PVE::Storage');
$storage->mock(
- config =>
- sub { { ids => { fabric => { type => 'nvmeof', subsysnqn => 'nqn.test' } } } },
+ config => sub { {
+ ids => {
+ fabric => { type => 'nvmeof', subsysnqn => 'nqn.test' },
+ zfs => { type => 'zfsnvme', subsysnqn => 'nqn.zfs' },
+ },
+ } },
);
$nvme->mock(is_supported => sub { 0 });
$nvme->mock(host_identity => sub { { nqn => 'nqn.host', id => 'uuid' } });
@@ -237,6 +241,13 @@ subtest 'node API contract' => sub {
trsvcid => 4420,
state => 'connecting',
},
+ nvme2 => {
+ subsystem => 'nqn.zfs',
+ transport => 'tcp',
+ traddr => '192.0.2.2',
+ trsvcid => 4420,
+ state => 'live',
+ },
} },
);
$nvme->mock(
@@ -246,6 +257,7 @@ subtest 'node API contract' => sub {
my $rows = $api->controllers({ node => 'n1' });
is($rows->[0]->{namespaces}, 2, 'namespaces counted for the subsystem of the controller');
is($rows->[0]->{'used-by-storage'}, 'fabric', 'controller attributed');
+ is($rows->[1]->{'used-by-storage'}, 'zfs', 'also the controller of a zfsnvme storage');
is($rows->[0]->{state}, 'connecting', 'kernel state remains visible');
for my $pair (['status', $status], ['controllers', $rows]) {
diff --git a/src/test/run_nvmeof_tests.pl b/src/test/run_nvmeof_tests.pl
index 02fccb46..1b94c032 100755
--- a/src/test/run_nvmeof_tests.pl
+++ b/src/test/run_nvmeof_tests.pl
@@ -109,6 +109,18 @@ subtest 'configuration, portals and volumes' => sub {
ok(!PVE::NVMeOF::in_cooldown($cfg, $first), 'adding it tries all portals again');
eval { $class->on_add_hook('second', {%$cfg}) };
like($@, qr/storage 'fabric' already uses this subsystem/, 'one storage per subsystem');
+ {
+ local $ids->{zfs} = { type => 'zfsnvme', subsysnqn => 'nqn.zfs' };
+ eval { $class->on_add_hook('second', { %$cfg, subsysnqn => 'nqn.zfs' }) };
+ like($@, qr/storage 'zfs' already uses this subsystem/,
+ 'also one of a zfsnvme storage');
+ is(PVE::NVMeOF::storage_subsystem($ids->{zfs}), 'nqn.zfs', 'it owns its subsystem');
+ is(
+ PVE::NVMeOF::storage_subsystem({ type => 'lvm', subsysnqn => 'x' }),
+ undef,
+ 'others not',
+ );
+ }
$ids->{vg} = { type => 'lvm', base => 'fabric:nvme-eui.0123456789abcdef', vgname => 'vg' };
my $images = { content => { images => 1 } };
eval { $class->on_update_hook_full('fabric', $cfg, $images, [], {}) };
diff --git a/src/test/run_san_lun_scan_tests.pl b/src/test/run_san_lun_scan_tests.pl
index 7fd9563b..82a79353 100755
--- a/src/test/run_san_lun_scan_tests.pl
+++ b/src/test/run_san_lun_scan_tests.pl
@@ -382,6 +382,17 @@ $config->mock(read_config => sub { { ids => { '3600map' => { type => 'wwid' } }
my $elsewhere = PVE::Storage::SAN::scan_luns($cfg);
is($elsewhere->[0]->{'paths-expected'}, undef, 'nor a storage of other nodes');
}
+{
+ local $cfg->{ids}->{fabric} = {
+ type => 'zfsnvme',
+ subsysnqn => 'nqn.test',
+ 'nvme-portals' => '192.0.2.1,192.0.2.2',
+ content => { images => 1 },
+ };
+ my $zfs = PVE::Storage::SAN::scan_luns($cfg);
+ is($zfs->[0]->{'used-by-storage'}, 'fabric', 'a zfsnvme storage uses its namespaces too');
+ is($zfs->[0]->{'paths-expected'}, undef, 'but its portals are not in the key of nvmeof');
+}
for my $base (qw(fabric nvme-fabric)) {
$cfg->{ids}->{data}->{base} = "$base:nvme-eui.0123456789abcdef";
$rows = PVE::Storage::SAN::scan_luns($cfg);
diff --git a/src/test/run_san_nvme_tests.pl b/src/test/run_san_nvme_tests.pl
index 86690318..bb35b30c 100755
--- a/src/test/run_san_nvme_tests.pl
+++ b/src/test/run_san_nvme_tests.pl
@@ -102,6 +102,10 @@ like($@, qr/serves images from this subsystem/, 'also when restricted to VM disk
$cfg->{ids}->{fabric}->{content} = { none => 1 };
eval { PVE::Storage::SAN::assert_lun_unreferenced($cfg, $lun) };
is($@, '', 'connection-only storage permits namespace initialization');
+$cfg->{ids} =
+ { zfs => { type => 'zfsnvme', subsysnqn => 'nqn.test', content => { images => 1 } } };
+eval { PVE::Storage::SAN::assert_lun_unreferenced($cfg, $lun) };
+like($@, qr/storage 'zfs' serves images from this subsystem/, 'a zfsnvme storage refuses too');
for my $nqn (undef, '') {
$disk->mock(read_subsysnqn => sub { $nqn });
--
2.54.0.windows.1
next prev parent reply other threads:[~2026-11-26 15:11 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-26 15:09 [PATCH storage v5 00/13] add ZFS over NVMe/TCP storage plugin Joaquin Varela
2026-11-26 15:09 ` [PATCH storage v5 01/13] zfsnvme: add target state parsing and planning Joaquin Varela
2026-11-26 15:09 ` [PATCH storage v5 02/13] zfsnvme: add the target transactions Joaquin Varela
2026-11-26 15:09 ` [PATCH storage v5 03/13] zfsnvme: add storage configuration and volume methods Joaquin Varela
2026-11-26 15:09 ` [PATCH storage v5 04/13] zfsnvme: connect the nodes and register the plugin Joaquin Varela
2026-11-26 15:09 ` Joaquin Varela [this message]
2026-11-26 15:09 ` [PATCH storage v5 06/13] api: config: check the cluster version before the first zfsnvme storage Joaquin Varela
2026-11-26 15:09 ` [PATCH storage v5 07/13] test: zfsnvme: add configuration and volume tests Joaquin Varela
2026-11-26 15:09 ` [PATCH storage v5 08/13] test: zfsnvme: add node side tests Joaquin Varela
2026-11-26 15:09 ` [PATCH storage v5 09/13] test: zfsnvme: add an in-memory nvmet target Joaquin Varela
2026-11-26 15:09 ` [PATCH storage v5 10/13] test: zfsnvme: test the target parsers and planners Joaquin Varela
2026-11-26 15:09 ` [PATCH storage v5 11/13] test: zfsnvme: test the target flows Joaquin Varela
2026-11-26 15:09 ` [PATCH storage v5 12/13] test: zfsnvme: add a fault sweep, renderer and taint tests Joaquin Varela
2026-11-26 15:09 ` [PATCH storage v5 13/13] zfsnvme: wait up to 30 seconds for the shared storage lock Joaquin Varela
2026-11-26 15:10 ` [PATCH docs v5] storage: document ZFS over NVMe/TCP Joaquin Varela
2026-11-26 15:11 ` [PATCH manager v5] ui: storage: add ZFS over NVMe/TCP editor Joaquin Varela
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=20261126150956.310593-6-joaquinvarela@neatech.ar \
--to=joaquinvarela@neatech.ar \
--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.