From: Thomas Lamprecht <t.lamprecht@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH v4 storage 03/25] api: disks: refuse a local wipe of a network NVMe namespace
Date: Mon, 23 Nov 2026 02:47:40 +0100 [thread overview]
Message-ID: <20261123020041.3728085-4-t.lamprecht@proxmox.com> (raw)
In-Reply-To: <20261123020041.3728085-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 | 14 ++++++++++++++
src/PVE/Diskmanage.pm | 12 +++++++++---
src/test/disk_api_test.pm | 20 ++++++++++++++++++--
3 files changed, 41 insertions(+), 5 deletions(-)
diff --git a/src/PVE/API2/Disks.pm b/src/PVE/API2/Disks.pm
index d157c430..79e37c31 100644
--- a/src/PVE/API2/Disks.pm
+++ b/src/PVE/API2/Disks.pm
@@ -318,6 +318,20 @@ __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 = $1;
+ die
+ "cannot wipe '$disk' - namespace '/dev/$namespace' is attached over a network"
+ . " or has no path, wipe it under Node > SAN\n"
+ if PVE::Diskmanage::is_network_nvme_transport(
+ PVE::Diskmanage::get_nvme_transport("/sys/block/$namespace"));
+ }
+
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 eb97eab7..45a67578 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..24553863 100644
--- a/src/test/disk_api_test.pm
+++ b/src/test/disk_api_test.pm
@@ -298,16 +298,32 @@ 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 /dev/nvme4n1p1 /dev/nvme4n1)
+ ) {
+ like($wipe->($name), qr/attached over a network/, "but not $name");
+ }
$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 2:01 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 ` [PATCH v4 storage 02/25] diskmanage: list NVMe namespaces attached over TCP or RDMA for SAN only Thomas Lamprecht
2026-11-23 1:47 ` Thomas Lamprecht [this message]
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-4-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