From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id B6E6C1FF14C for ; Fri, 26 Jun 2026 14:11:27 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id A3AA3F881; Fri, 26 Jun 2026 14:10:55 +0200 (CEST) From: Thomas Lamprecht To: pve-devel@lists.proxmox.com Subject: [PATCH storage 04/13] multipath: add storage plugin for multipath LUNs Date: Fri, 26 Jun 2026 14:07:34 +0200 Message-ID: <20260626121000.2095591-5-t.lamprecht@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260626121000.2095591-1-t.lamprecht@proxmox.com> References: <20260626121000.2095591-1-t.lamprecht@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1782475801439 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.005 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment 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: DTR3JVNEONZM4MPYXOGKBVUC46GUJHPC X-Message-ID-Hash: DTR3JVNEONZM4MPYXOGKBVUC46GUJHPC X-MailFrom: t.lamprecht@proxmox.com 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: Expose the dm-multipath maps present on a node as a first-class storage of raw volumes, each keyed by its WWID and reachable at the WWID-stable path /dev/disk/by-id/dm-uuid-mpath-. The maps are assembled by multipathd from the cluster-wide allow-list, so the storage carries no configuration of its own and only reflects what is already there. This is meant primarily as the base of a shared LVM storage, giving a volume group on a multipath LUN full path redundancy without any manual device wiring. Signed-off-by: Thomas Lamprecht --- src/PVE/Storage.pm | 2 + src/PVE/Storage/Makefile | 3 +- src/PVE/Storage/MultipathPlugin.pm | 186 +++++++++++++++++++++++++++++ 3 files changed, 190 insertions(+), 1 deletion(-) create mode 100644 src/PVE/Storage/MultipathPlugin.pm diff --git a/src/PVE/Storage.pm b/src/PVE/Storage.pm index 64ea9da..4daeecf 100755 --- a/src/PVE/Storage.pm +++ b/src/PVE/Storage.pm @@ -39,6 +39,7 @@ use PVE::Storage::ZFSPlugin; use PVE::Storage::PBSPlugin; use PVE::Storage::BTRFSPlugin; use PVE::Storage::ESXiPlugin; +use PVE::Storage::MultipathPlugin; # Storage API version. Increment it on changes in storage API interface. use constant APIVER => 15; @@ -64,6 +65,7 @@ PVE::Storage::ZFSPlugin->register(); PVE::Storage::PBSPlugin->register(); PVE::Storage::BTRFSPlugin->register(); PVE::Storage::ESXiPlugin->register(); +PVE::Storage::MultipathPlugin->register(); # load third-party plugins if (-d '/usr/share/perl5/PVE/Storage/Custom') { diff --git a/src/PVE/Storage/Makefile b/src/PVE/Storage/Makefile index a67dc25..d76ec25 100644 --- a/src/PVE/Storage/Makefile +++ b/src/PVE/Storage/Makefile @@ -14,7 +14,8 @@ SOURCES= \ PBSPlugin.pm \ BTRFSPlugin.pm \ LvmThinPlugin.pm \ - ESXiPlugin.pm + ESXiPlugin.pm \ + MultipathPlugin.pm .PHONY: install install: diff --git a/src/PVE/Storage/MultipathPlugin.pm b/src/PVE/Storage/MultipathPlugin.pm new file mode 100644 index 0000000..91fc489 --- /dev/null +++ b/src/PVE/Storage/MultipathPlugin.pm @@ -0,0 +1,186 @@ +package PVE::Storage::MultipathPlugin; + +use strict; +use warnings; + +use PVE::Multipath; +use PVE::Storage::Plugin; + +use base qw(PVE::Storage::Plugin); + +# A block-LUN provider over device-mapper multipath: it exposes the maps present on the node as raw +# volumes keyed by their WWID, reachable at the WWID-stable /dev/disk/by-id/dm-uuid-mpath- +# path. The maps are assembled by multipathd from the cluster-wide allow-list, so this storage has +# no configuration of its own and only reflects what is there. Its main use is as the 'base' of a +# shared LVM storage. + +sub type { + return 'multipath'; +} + +sub plugindata { + return { + content => [{ images => 1, none => 1 }, { images => 1 }], + format => [{ raw => 1 }, 'raw'], + select_existing => 1, + 'sensitive-properties' => {}, + }; +} + +sub properties { + return {}; +} + +sub options { + return { + nodes => { optional => 1 }, + shared => { optional => 1 }, + disable => { optional => 1 }, + content => { optional => 1 }, + bwlimit => { optional => 1 }, + }; +} + +# the volume name is the LUN's WWID +sub parse_volname { + my ($class, $volname) = @_; + + if ($volname =~ m!^([a-zA-Z0-9._:-]+)$!) { + return ('images', $1, undef, undef, undef, undef, 'raw'); + } + + die "unable to parse multipath volume name '$volname'\n"; +} + +sub filesystem_path { + my ($class, $scfg, $volname, $snapname) = @_; + + die "snapshot is not possible on multipath storage\n" if defined($snapname); + + my ($vtype, $wwid, $vmid) = $class->parse_volname($volname); + + my $path = "/dev/disk/by-id/dm-uuid-mpath-$wwid"; + + return wantarray ? ($path, $vmid, $vtype) : $path; +} + +sub create_base { + die "can't create base images in multipath storage\n"; +} + +sub clone_image { + die "can't clone images in multipath storage\n"; +} + +sub alloc_image { + die "can't allocate space in multipath storage\n"; +} + +sub free_image { + die "can't free space in multipath storage\n"; +} + +sub list_images { + my ($class, $storeid, $scfg, $vmid, $vollist, $cache) = @_; + + my $res = []; + + # multipath LUNs have no owning guest + return $res if defined($vmid) && !$vollist; + + $cache->{multipath_maps} //= eval { PVE::Multipath::get_maps() } // []; + + for my $map ($cache->{multipath_maps}->@*) { + next if !defined($map->{wwid}); + + my $volid = "$storeid:$map->{wwid}"; + if ($vollist) { + next if !grep { $_ eq $volid } @$vollist; + } + + push @$res, + { + volid => $volid, + format => 'raw', + size => $map->{size} // 0, + vmid => 0, + }; + } + + return $res; +} + +sub list_volumes { + my ($class, $storeid, $scfg, $vmid, $content_types) = @_; + + my $res = $class->list_images($storeid, $scfg, $vmid); + $_->{content} = 'images' for $res->@*; + + return $res; +} + +sub status { + my ($class, $storeid, $scfg, $cache) = @_; + + my $active = PVE::Multipath::is_running() ? 1 : 0; + + return (0, 0, 0, $active); +} + +sub activate_storage { + my ($class, $storeid, $scfg, $cache) = @_; + + PVE::Multipath::assert_supported(); + # nothing to log into: multipathd assembles the maps from the allow-list +} + +sub deactivate_storage { + my ($class, $storeid, $scfg, $cache) = @_; + + # the maps are shared infrastructure, do not tear them down +} + +sub check_connection { + my ($class, $storeid, $scfg) = @_; + + return PVE::Multipath::is_running() ? 1 : 0; +} + +sub activate_volume { + my ($class, $storeid, $scfg, $volname, $snapname, $cache) = @_; + + my ($vtype, $wwid) = $class->parse_volname($volname); + + my $map = PVE::Multipath::wait_for_map($wwid); + die "multipath map for WWID '$wwid' is not present - is it in the multipath" + . " allow-list and are its paths up?\n" + if !$map; +} + +sub deactivate_volume { + my ($class, $storeid, $scfg, $volname, $snapname, $cache) = @_; + + # do not drop the map, it is shared infrastructure +} + +sub volume_resize { + my ($class, $scfg, $storeid, $volname, $size, $running) = @_; + + die "volume resize is not possible on multipath storage\n"; +} + +sub volume_has_feature { + my ($class, $scfg, $feature, $storeid, $volname, $snapname, $running) = @_; + + return { copy => { current => 1 } }->{$feature}->{current}; +} + +sub volume_export_formats { + return (); +} + +sub volume_import_formats { + return (); +} + +1; -- 2.47.3