From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [45.144.208.40]) by lore.proxmox.com (Postfix) with ESMTPS id 5F2AE1FF0B3 for ; Thu, 26 Nov 2026 16:11:07 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 99E81217C2; Thu, 26 Nov 2026 16:10:56 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=neatech-ar.20260707.gappssmtp.com; s=20260707; t=1795705807; x=1796310607; darn=lists.proxmox.com; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=WPxOwzByT4GN/52a5oZ/9j3yBg6GynpT+3VzKHgBupA=; b=GJQn0fN7Z8ht5Gr5o2PwsQ0vdGiBmgFeWo4vTMFkOqxnkVlxWMEbzJqCLnaFTTE3P0 dYu0UN4ATsqjlHEHD1E/d5PN1K5tziPLUz/VseskGw99EADDLi/FA7JE0tQqVeXxAJDH 1IcvgXy2q78emHSAP5aeNNMhfU7rvws3t1AGof6tZZ5XiApjLh2FebYH4nsn7mN29Ok1 BUKiCxOJ7s91yEaFQ4BC45izF4tls8C1I4CgcMFWu7BKKneh+fCIqSIQCYO7/tzTM/s6 Poxzz5hOut2LSNy/QrVlJidfEuZ10oCB6bsOXpHpxx4z4D+c8A9FQ1Xs/HG9p2pyEUEp qUAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795705807; x=1796310607; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=WPxOwzByT4GN/52a5oZ/9j3yBg6GynpT+3VzKHgBupA=; b=wrvyJ7EZ9fMqVsh5ZldlbD+gEMNvn/CEExLkWy9Q4hEuH1lf5r6UV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r24kIVjybWk8CoUD25SKwCFij/23sgrFu4wIqdKIpQ3bfPo/y s7J0PyFd5M+O6OQTqFRl0otyZ5NCLlQ== X-Received: by 2002:a05:6102:6309:10b0:7c3:83a9:eddd with SMTP id ada2fe7eead31-7d72b37ca78mr13923710137.1.1795705807116; Thu, 26 Nov 2026 07:10:07 -0800 (PST) From: Joaquin Varela 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 Message-ID: <20261126150956.310593-6-joaquinvarela@neatech.ar> X-Mailer: git-send-email 2.54.0.windows.1 In-Reply-To: <20261126150956.310593-1-joaquinvarela@neatech.ar> References: <20261126150956.310593-1-joaquinvarela@neatech.ar> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.250 Adjusted score from AWL reputation of From: address DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DMARC_PASS -0.1 DMARC pass policy RCVD_IN_DNSWL_NONE -0.0001 Sender listed at https://www.dnswl.org/, no trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: 4TJCIPQPVL6DQ47IAZULAIQMJKCUDRTA X-Message-ID-Hash: 4TJCIPQPVL6DQ47IAZULAIQMJKCUDRTA X-MailFrom: joaquinvarela@neatech.ar X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: 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 --- 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