* [RFC] storage: SAN LUN view treats LUNs of third-party plugins as unused, so they can be wiped
@ 2026-11-24 20:03 Dirk Nehring
2026-11-26 18:39 ` Ciro Iriarte
0 siblings, 1 reply; 4+ messages in thread
From: Dirk Nehring @ 2026-11-24 20:03 UTC (permalink / raw)
To: pve-devel
Hi,
reading the new SAN code in pve-storage (git 2c98567, 9.1.24), I think it
can wipe the disk of a running guest when the disk is a LUN of a
third-party storage plugin. I have not tested it yet: the packages are
not in the repositories yet, so this is from the code only.
Our plugin (NetApp ONTAP, iSCSI/FC/NVMe-TCP) gives every guest disk its
own LUN or namespace. It maps that LUN to one igroup that holds every node
of the cluster, so each node sees each LUN all the time, as a dm-multipath
map (WWID 3600a0980...) or as a namespace of one subsystem. The TrueNAS
plugin works the same way. The storage section of such a plugin has none
of the keys the new code looks for: there is no `target`, `vgname`, `base`
or nvmeof `subsysnqn`.
What the new code does with such a LUN:
- PVE::Storage::SAN::scan_luns() takes the owner of a LUN only from
`base`, `vgname`, `target` (when the storage serves images) or the
`subsysnqn` of an nvmeof storage. A LUN of a third-party plugin
therefore has no `used-by-storage`. Its usage stays 'unused' unless a
process on *this* node has it open. The comment in scan_luns() names
third-party plugins as one way a guest uses a LUN, but the check that
follows looks only at local openers and partitions.
- wipe_lun() calls assert_lun_unreferenced(), which knows the same four
keys, and then assert_lun_paths_unused(), which looks only at local
openers, holders and mounts. LVMPlugin.pm:388 runs the same check before
a volume group is created on a LUN.
Scenario: VM 100 runs on node A with its disk on LUN X. On node B, LUN X
is listed as unused under Node > SAN, because nothing on node B has it
open. A wipe there passes every check and destroys the disk of the
running guest. The same happens to every disk of a stopped VM, and on
every node.
The local opener check cannot fix this: the guest that uses the LUN runs
on another node, or does not run at all. Nothing in the storage config
tells core which LUNs a third-party plugin owns. Only the plugin knows.
Proposal: an optional plugin method that core asks for every enabled
storage of a plugin that implements it, in scan_luns() and in
assert_lun_unreferenced(). For example:
# Returns true if this storage owns the LUN or namespace.
# $lun: the WWID, and when known the iSCSI target or NVMe subsystem.
sub san_lun_owned { my ($class, $storeid, $scfg, $lun) = @_; ... }
or a list form, so that scan_luns() needs one call per storage and not one
per LUN:
# WWIDs (SCSI) and namespace IDs (NVMe) of the volumes on this storage.
sub san_volumes { my ($class, $storeid, $scfg) = @_; ... }
A die in the method should count as "owned", so that an unreachable array
never makes its LUNs wipeable. Until plugins implement the method, a
warning in the wipe and VG dialogs would already help: a LUN without an
owner can still belong to a third-party storage that core cannot see.
Our plugin can answer either form from data it already caches, and we
would implement the method and test it on our clusters once there is an
interface. If I misread the code and there is already a way for a plugin
to claim its LUNs, I would be glad to hear it.
Thanks,
Dirk Nehring
MARCANT AG
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFC] storage: SAN LUN view treats LUNs of third-party plugins as unused, so they can be wiped
2026-11-24 20:03 Dirk Nehring
@ 2026-11-26 18:39 ` Ciro Iriarte
2026-11-27 18:30 ` Thomas Lamprecht
0 siblings, 1 reply; 4+ messages in thread
From: Ciro Iriarte @ 2026-11-26 18:39 UTC (permalink / raw)
To: pve-devel; +Cc: Dirk Nehring, t.lamprecht
On 24/11/2026 21:03, Dirk Nehring wrote:
> reading the new SAN code in pve-storage (git 2c98567, 9.1.24), I think it
> can wipe the disk of a running guest when the disk is a LUN of a
> third-party storage plugin.
I read SAN.pm on current master and came to the same conclusion.
scan_luns() sets used-by-storage only from base, vgname, target and
the nvmeof subsysnqn, and assert_lun_unreferenced() checks the same
keys. For anything else, the only protection is a writable opener on
the node doing the check.
I maintain pve-FCLUPlugin, which uses the same layout over Fibre
Channel: one array volume per guest disk, currently with a Hitachi
VSP driver. It is less exposed than an igroup with every node, because
it maps a volume only to the node that activates it and unmaps it on
deactivate. A LUN can still stay mapped on a node that no longer has
it open. If deactivate fails after a migration or backup, or a node
crashes or loses access to the array, the mapping stays in place until
cleaned up. On that node, the SAN view shows the disk as unused while
the guest runs elsewhere.
> or a list form, so that scan_luns() needs one call per storage and not one
> per LUN:
>
> # WWIDs (SCSI) and namespace IDs (NVMe) of the volumes on this storage.
> sub san_volumes { my ($class, $storeid, $scfg) = @_; ... }
I prefer the list form. The plugin keeps a cluster-wide volume registry
in pmxcfs that already records each volume's device identity, so it can
answer without querying the array. That matters if the check runs when
the GUI lists LUNs. Volumes created for snapshots can be mapped as well,
so the list should cover every volume the plugin may map, not just
current images.
> A die in the method should count as "owned", so that an unreachable array
> never makes its LUNs wipeable.
Agreed. A related case is a storage whose plugin fails to load, since
core cannot query it either. Refusing a wipe whenever such a storage
is configured may be too strict, but the dialog could at least warn
about it. If that case matters enough, an alternative is for core to
keep the WWIDs itself, recorded by the plugin on alloc and free, so the
SAN view does not depend on the plugin being reachable at all.
If an interface like this is accepted, I'll implement it in
pve-FCLUPlugin and test it on our lab cluster (PVE 9.3, FC multipath),
including the stale mapping cases above.
Ciro
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFC] storage: SAN LUN view treats LUNs of third-party plugins as unused, so they can be wiped
@ 2026-11-27 8:27 Mohamed ALLOUACHE
0 siblings, 0 replies; 4+ messages in thread
From: Mohamed ALLOUACHE @ 2026-11-27 8:27 UTC (permalink / raw)
To: cyruspy; +Cc: dnehring, pve-devel, t.lamprecht
I have been thinking about possible approaches to make SAN LUN ownership
checks safer.
In addition to the proposed san_volumes() plugin interface, I think there
are a few aspects worth considering:
Explicit ownership states
The core should distinguish between owned, confirmed_unused, and unknown. A
plugin error, timeout, or missing ownership information should never be
interpreted as proof that a LUN is unused.
Cluster-wide ownership information
A registry in pmxcfs could be considered as a complementary mechanism.
Plugins could register volume identities when allocating volumes and update
the records when freeing them. This could help preserve ownership
information even when a plugin cannot currently be queried.
Such a registry would need reconciliation and stale-record handling, so I
would not make it the sole source of truth without further design work.
Destructive-operation locking
Ownership should be checked again immediately before wiping a LUN, under an
appropriate lock shared with volume allocation operations. This would help
avoid TOCTOU races between the ownership check and the actual wipe.
Explicit plugin capabilities
It may also be useful for plugins to declare whether they support SAN
ownership discovery, so the core can distinguish unsupported ownership
checks from a confirmed empty result.
I would suggest starting with the plugin-provided volume list and
fail-closed behavior, while keeping the registry and capability mechanisms
open for discussion.
The important point is that an inability to determine ownership must not be
treated as an unused LUN when performing destructive operations.
Mohamed
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFC] storage: SAN LUN view treats LUNs of third-party plugins as unused, so they can be wiped
2026-11-26 18:39 ` Ciro Iriarte
@ 2026-11-27 18:30 ` Thomas Lamprecht
0 siblings, 0 replies; 4+ messages in thread
From: Thomas Lamprecht @ 2026-11-27 18:30 UTC (permalink / raw)
To: Ciro Iriarte, pve-devel; +Cc: Dirk Nehring
Am 26.11.26 um 19:39 schrieb Ciro Iriarte:
> On 24/11/2026 21:03, Dirk Nehring wrote:
>> reading the new SAN code in pve-storage (git 2c98567, 9.1.24), I think it
>> can wipe the disk of a running guest when the disk is a LUN of a
>> third-party storage plugin.
>
> I read SAN.pm on current master and came to the same conclusion.
> scan_luns() sets used-by-storage only from base, vgname, target and
> the nvmeof subsysnqn, and assert_lun_unreferenced() checks the same
> keys. For anything else, the only protection is a writable opener on
> the node doing the check.
FYI, the web UI is now more clear about this, that was the simplest
stop gap.
> I maintain pve-FCLUPlugin, which uses the same layout over Fibre
> Channel: one array volume per guest disk, currently with a Hitachi
> VSP driver. It is less exposed than an igroup with every node, because
> it maps a volume only to the node that activates it and unmaps it on
> deactivate. A LUN can still stay mapped on a node that no longer has
> it open. [...]
>
>> or a list form, so that scan_luns() needs one call per storage and not one
>> per LUN:
>>
>> # WWIDs (SCSI) and namespace IDs (NVMe) of the volumes on this storage.
>> sub san_volumes { my ($class, $storeid, $scfg) = @_; ... }
>
> I prefer the list form. The plugin keeps a cluster-wide volume registry
> in pmxcfs that already records each volume's device identity, so it can
> answer without querying the array. That matters if the check runs when
> the GUI lists LUNs. Volumes created for snapshots can be mapped as well,
> so the list should cover every volume the plugin may map, not just
> current images.
Agreed on the list form and on including every LUN a storage may map
(guest disks, snapshots, clones, and stale mappings). I'd do it like
this (with APIVER 18, APIAGE 9 compat bump):
$info = $class->backing_devices($storeid, $scfg, $opts)
It returns the WWIDs the storage owns (or device paths, iSCSI targets,
NVMe subsystems, or LVM VGs), for example:
{
wwids => {
'3600a098038314c4a' => { volid => "$storeid:vm-100-disk-0" },
'eui.0123456789abcdef' => { native => 1, nodes => [$node] },
},
}
Each WWID entry can optionally return `paths-expected`, `native` (for
native NVMe multipath namespaces), and `nodes` (so per-host attached
LUNs are not flagged as missing on other nodes in cluster SAN status).
The returned hashref defaults to `status => 'complete'`, so `{}` is a
valid empty result.
`$opts` would be a hashref telling the plugin how it is being called:
`$opts->{live}` would be `0` for listing and status views (under a
short timeout budget, so plugins stay local-only and can return
`status => 'partial'` with whatever is cached locally), and `1` before
destructive operations (wipe, VG create/remove, last-path NVMe-oF
disconnect), where core would call third-party plugins once outside
locks and plugins may query their backend. On `live => 1` calls, core
may also pass `$opts->{candidates}` (`{ wwids => [...], devices => [...] }`)
as an optional hint so plugins can do point lookups instead of listing
every LUN. Core would still never write multipathd config for
third-party plugins.
>> A die in the method should count as "owned", so that an unreachable array
>> never makes its LUNs wipeable.
>
> Agreed. A related case is a storage whose plugin fails to load, since
> core cannot query it either. Refusing a wipe whenever such a storage
> is configured may be too strict, but the dialog could at least warn
> about it. If that case matters enough, an alternative is for core to
> keep the WWIDs itself, recorded by the plugin on alloc and free, so the
> SAN view does not depend on the plugin being reachable at all.
In the proposed series, any LUN a plugin reports as in use would always
be blocked from wipes and VG creation, even if the storage is disabled
or restricted to other nodes. If a plugin dies, times out, returns
`status => 'partial'` or `'unknown'`, or failed to load on the node,
core would refuse the operation while that storage is enabled here and
print a hint to disable or restrict it so one broken backend does not
block unrelated LUNs. Existing plugins that do not implement
`backing_devices()` would inherit `undef` and fall back to
`storage.cfg` fields plus a live `list_images()`/`path()` check.
Starting with `backing_devices()` avoids a separate core WWID registry
in pmxcfs that would have to be kept in sync across crashes and
array-side changes, i.e. many foot-guns and error potential and not
scaling well on a bigger cluster.
> If an interface like this is accepted, I'll implement it in
> pve-FCLUPlugin and test it on our lab cluster (PVE 9.3, FC multipath),
> including the stale mapping cases above.
I'll probably send the patch series to the list in the next days; early
feedback on the interface would be already welcome though.
- Thomas
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-11-27 18:30 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-27 8:27 [RFC] storage: SAN LUN view treats LUNs of third-party plugins as unused, so they can be wiped Mohamed ALLOUACHE
-- strict thread matches above, loose matches on Subject: below --
2026-11-24 20:03 Dirk Nehring
2026-11-26 18:39 ` Ciro Iriarte
2026-11-27 18:30 ` Thomas Lamprecht
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox