From: Thomas Lamprecht <t.lamprecht@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH v5 storage 08/26] lvm: allow a volume group on an NVMe over Fabrics namespace
Date: Mon, 23 Nov 2026 14:32:00 +0100 [thread overview]
Message-ID: <20261123133412.3710030-9-t.lamprecht@proxmox.com> (raw)
In-Reply-To: <20261123133412.3710030-1-t.lamprecht@proxmox.com>
An LVM storage only accepts an iSCSI LUN as base volume. Accept a
namespace of an NVMe over Fabrics storage too. Adding such an LVM
storage connects the subsystem, waits for the namespace and creates
the volume group on it, and activating it on another node connects
that node first.
The creation treats the namespace like any SAN LUN: it takes the
cluster-wide lock of the LUN and refuses a namespace that another
storage references. A namespace that is not recognized as one, for
example as its last path is gone, is refused rather than taken as a
local disk. A base storage that offers its namespaces as guest disks is
refused, also for an existing volume group, as a guest could otherwise
get the namespace of the group as its disk.
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---
src/PVE/Storage/LVMPlugin.pm | 24 +++++++++++++++----
src/test/run_san_nvme_tests.pl | 42 ++++++++++++++++++++++++++++++++++
2 files changed, 61 insertions(+), 5 deletions(-)
diff --git a/src/PVE/Storage/LVMPlugin.pm b/src/PVE/Storage/LVMPlugin.pm
index b759554c..dd267b34 100644
--- a/src/PVE/Storage/LVMPlugin.pm
+++ b/src/PVE/Storage/LVMPlugin.pm
@@ -427,7 +427,13 @@ sub lvm_create_volume_group {
my ($device, $vgname, $shared, $guard) = @_;
require PVE::Storage::SAN;
my $lun = PVE::Storage::SAN::lun_for_device($device);
- return create_volume_group($device, $vgname, undef, $guard) if !$lun;
+ if (!$lun) {
+ # a namespace whose transport cannot be read, like one without a path, is no local disk
+ die "cannot use '$device' - it is not recognized as a SAN LUN, for example as it has no"
+ . " path\n"
+ if $guard && $guard->{'san-only'};
+ return create_volume_group($device, $vgname, undef, $guard);
+ }
PVE::Storage::SAN::with_lun_lock(
$lun,
sub { create_volume_group($device, $vgname, $lun, $guard) },
@@ -1355,9 +1361,12 @@ sub on_add_hook {
my $basecfg = PVE::Storage::storage_config($cfg, $baseid, 1);
die "base storage ID '$baseid' does not exist\n" if !$basecfg;
- # we only support iscsi for now
- die "unsupported base type '$basecfg->{type}'"
- if $basecfg->{type} ne 'iscsi';
+ die "unsupported base storage type '$basecfg->{type}' - expected iscsi or nvmeof\n"
+ if $basecfg->{type} ne 'iscsi' && $basecfg->{type} ne 'nvmeof';
+ # with direct use, a guest can get the namespace as disk, also with an existing group on it
+ die "storage '$baseid' offers its namespaces as disk images - if no guest uses them"
+ . " directly, set its content to 'none'\n"
+ if $basecfg->{type} eq 'nvmeof' && PVE::Storage::san_storage_serves_images($basecfg);
# Managed multipath requires the coalesced map or a partition of it, never a transient
# single-path PV.
@@ -1399,7 +1408,12 @@ sub on_add_hook {
$path,
$scfg->{vgname},
$scfg->{shared},
- { check_storage => $check_target, exempt => $storeid },
+ {
+ check_storage => $check_target,
+ exempt => $storeid,
+ # the volumes of an NVMe over Fabrics storage are whole namespaces
+ 'san-only' => $basecfg->{type} eq 'nvmeof',
+ },
);
}
diff --git a/src/test/run_san_nvme_tests.pl b/src/test/run_san_nvme_tests.pl
index 61872a60..86690318 100755
--- a/src/test/run_san_nvme_tests.pl
+++ b/src/test/run_san_nvme_tests.pl
@@ -149,4 +149,46 @@ is_deeply(
);
is_deeply(\@opens, [$link], 'VG creation holds the native by-id device');
+$cfg->{ids} = { fabric => { type => 'nvmeof', subsysnqn => 'nqn.test', content => { none => 1 } } };
+my @activation;
+my $add = sub {
+ PVE::Storage::LVMPlugin->on_add_hook(
+ 'data',
+ { base => 'fabric:nvme-eui.0123456789abcdef', vgname => 'data', shared => 1 },
+ );
+};
+$storage->mock(path => sub { $link });
+$storage->mock(activate_storage => sub { push @activation, 'storage' });
+$storage->mock(activate_volumes => sub { push @activation, 'volume' });
+$lvm->mock(
+ lvm_create_volume_group => sub {
+ is($_[0], $link, 'add hook passes native base');
+ is($_[3]->{exempt}, 'data', 'add hook exempts new storage');
+ ok($_[3]->{'san-only'}, 'and takes the namespace only as SAN LUN');
+ },
+);
+$add->();
+is_deeply(\@activation, ['storage', 'volume'], 'LVM activates the NVMe base before creation');
+$lvm->unmock('lvm_create_volume_group');
+
+# an existing volume group of the same name is taken over without writes
+@order = ();
+$lvm->mock(lvm_pv_info => sub { { vgname => 'data', in_use => 1 } });
+$add->();
+is_deeply(\@order, [qw(lock unlock)], 'an existing volume group is taken over');
+$lvm->mock(lvm_pv_info => sub { undef });
+
+@activation = ();
+$cfg->{ids}->{fabric}->{content} = { images => 1 };
+eval { $add->() };
+like($@, qr/offers its namespaces as disk images/, 'a base with direct use refuses');
+is_deeply(\@activation, [], 'before it activates anything');
+$cfg->{ids}->{fabric}->{content} = { none => 1 };
+
+@order = ();
+$disk->mock(get_nvme_transport => sub { undef });
+eval { $add->() };
+like($@, qr/not recognized as a SAN LUN/, 'a namespace without transport is no local disk');
+is_deeply(\@order, [], 'and nothing is written to it');
+
done_testing();
next prev parent reply other threads:[~2026-11-23 13:35 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 ` Thomas Lamprecht [this message]
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 ` [PATCH v5 storage 11/26] api: san luns: attribute NVMe namespaces to storage Thomas Lamprecht
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-9-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.