From: Thomas Lamprecht <t.lamprecht@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH v5 storage 04/26] api: disks: refuse a local wipe of a network NVMe namespace
Date: Mon, 23 Nov 2026 14:31:56 +0100 [thread overview]
Message-ID: <20261123133412.3710030-5-t.lamprecht@proxmox.com> (raw)
In-Reply-To: <20261123133412.3710030-1-t.lamprecht@proxmox.com>
The disk lists leave out NVMe namespaces attached over TCP or RDMA, but
the wipe API still took a partition of one by its kernel name. It then
checked only for mounts and holders on this node, while other nodes can
use the namespace, for example through an nvmeof storage that serves it
as disk image. A whole namespace whose last controller is gone took the
same path, as its transport cannot be read, and with I/O that waits for
a path, the wipe went through once a path returned. Refuse both, taking
a namespace of unknown transport as one over a network. Node > SAN
wipes the namespace as a whole, with the checks of the SAN code.
Partitions of iSCSI and Fibre Channel LUNs are still wiped like those of
local disks.
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---
src/PVE/API2/Disks.pm | 23 +++++++++++++++++++++++
src/PVE/Diskmanage.pm | 12 +++++++++---
src/test/disk_api_test.pm | 26 ++++++++++++++++++++++++--
3 files changed, 56 insertions(+), 5 deletions(-)
diff --git a/src/PVE/API2/Disks.pm b/src/PVE/API2/Disks.pm
index d157c430..f9b79e7a 100644
--- a/src/PVE/API2/Disks.pm
+++ b/src/PVE/API2/Disks.pm
@@ -318,6 +318,29 @@ __PACKAGE__->register_method({
. " SAN LUN\n";
}
+ # Other nodes can use a namespace attached over a network, which the checks for mounts
+ # and holders do not see, and one without a path gets written once it has one again.
+ # Under Node > SAN, it is wiped as a whole with the SAN checks. The name tells the
+ # namespace of a partition, also if its partition number is one that the checks of the
+ # partition table refuse.
+ if (basename($disk) =~ m/^(nvme[0-9]+n[0-9]+)(p[0-9]+)?$/) {
+ my ($namespace, $partition) = ($1, $2);
+ my $transport = PVE::Diskmanage::get_nvme_transport("/sys/block/$namespace");
+ die
+ "cannot wipe '$disk' - the transport of namespace '/dev/$namespace' cannot be"
+ . " read, as when it has no path\n"
+ if !defined($transport);
+ if (PVE::Diskmanage::is_network_nvme_transport($transport)) {
+ die
+ "cannot wipe '$disk' - a partition of namespace '/dev/$namespace', which"
+ . " is attached over a network, cannot be wiped on its own; Node > SAN"
+ . " wipes the whole namespace\n"
+ if defined($partition);
+ # it got a path since the SAN check above, which found none
+ die "cannot wipe '$disk' - its transport changed, try again\n";
+ }
+ }
+
my $mounted = PVE::Diskmanage::is_mounted($disk);
die "disk/partition '${mounted}' is mounted\n" if $mounted;
diff --git a/src/PVE/Diskmanage.pm b/src/PVE/Diskmanage.pm
index d70647c8..2790aedf 100644
--- a/src/PVE/Diskmanage.pm
+++ b/src/PVE/Diskmanage.pm
@@ -578,6 +578,14 @@ sub get_nvme_transport {
return $first;
}
+# A namespace attached over TCP or RDMA is no local disk, and neither is one whose transport is
+# unknown, like one whose last controller is gone, which can be one over a network.
+sub is_network_nvme_transport {
+ my ($transport) = @_;
+
+ return !defined($transport) || $transport =~ m/^(?:tcp|rdma)$/;
+}
+
# SAS does not distinguish local from remote attachments, so it is not classified as remote.
sub is_remote_transport {
my ($transport) = @_;
@@ -691,10 +699,8 @@ sub get_disks {
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 && is_network_nvme_transport($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;
diff --git a/src/test/disk_api_test.pm b/src/test/disk_api_test.pm
index 1d2f8d33..3ae932e0 100644
--- a/src/test/disk_api_test.pm
+++ b/src/test/disk_api_test.pm
@@ -298,16 +298,38 @@ subtest 'wipe takes names beyond the old pattern for a LUN only' => sub {
for my $name (@other) {
like($wipe->($name), qr/only accepted for a SAN LUN/, "$name is refused");
}
+ my %transport = (nvme1n1 => 'pcie', nvme2n1 => 'tcp', nvme3n1 => 'rdma', nvme4n1 => undef);
+ $diskmanage_module->mock(
+ get_nvme_transport => sub { $transport{ (split('/', $_[0]))[-1] } });
is($wipe->('/dev/sdb1'), '', 'a partition by its kernel name is wiped');
+ is($wipe->('/dev/nvme1n1p1'), '', 'so is one of a local namespace');
+ is($wipe->('/dev/nvme1n1'), '', 'and a local namespace');
+ for my $name (qw(/dev/nvme2n1p1 /dev/nvme2n1p200 /dev/nvme3n1p1)) {
+ like(
+ $wipe->($name),
+ qr/attached over a network, cannot be wiped on its own/,
+ "but not $name",
+ );
+ }
+ for my $name (qw(/dev/nvme4n1p1 /dev/nvme4n1)) {
+ like($wipe->($name), qr/transport of namespace .* cannot be read/, "nor $name");
+ }
+ like($wipe->('/dev/nvme2n1'), qr/transport changed/, 'nor one the SAN check missed');
$lun = { wwid => '3600a' };
is(
$wipe->('/dev/disk/by-id/dm-uuid-mpath-3600a'),
'',
'a LUN by the name of its map is wiped',
);
- is_deeply(\@wiped, ['/dev/sdb1', '3600a'], 'nothing else got wiped');
+ is_deeply(
+ \@wiped,
+ ['/dev/sdb1', '/dev/nvme1n1p1', '/dev/nvme1n1', '3600a'],
+ 'nothing else got wiped',
+ );
- my @mocked = qw(verify_blockdev_path is_mounted has_holder wipe_blockdev udevadm_trigger);
+ my @mocked = qw(
+ verify_blockdev_path is_mounted has_holder wipe_blockdev udevadm_trigger get_nvme_transport
+ );
$diskmanage_module->unmock($_) for @mocked;
};
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 ` Thomas Lamprecht [this message]
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 ` [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-5-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox