From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [IPv6:2a0f:8001:1:32::40]) by lore.proxmox.com (Postfix) with ESMTPS id 733AE1FF0AA for ; Tue, 17 Nov 2026 21:42:05 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 89B96217F6; Tue, 17 Nov 2026 21:40:53 +0100 (CET) From: "Max R. Carrara" To: pve-devel@lists.proxmox.com Subject: [PATCH pve-storage v3 14/51] storage: heave vtype file path parsing logic inside loop into helper Date: Tue, 17 Nov 2026 21:38:46 +0100 Message-ID: <20261117203953.913035-15-m.carrara@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261117203953.913035-1-m.carrara@proxmox.com> References: <20261117203953.913035-1-m.carrara@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1794948022886 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.265 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust 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: NRQ6GBQZMAT2SUFJITSO2P3EHFXY46UL X-Message-ID-Hash: NRQ6GBQZMAT2SUFJITSO2P3EHFXY46UL X-MailFrom: m.carrara@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 CC: Wolfgang Bumiller X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Signed-off-by: Max R. Carrara --- src/PVE/Storage.pm | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/PVE/Storage.pm b/src/PVE/Storage.pm index 840b3687..f5c866db 100755 --- a/src/PVE/Storage.pm +++ b/src/PVE/Storage.pm @@ -734,14 +734,12 @@ sub path_to_volume_id { # Note: abs_path() return undef if $path doesn not exist # for example when nfs storage is not mounted $path = abs_path($path) || $path; - for my $sid (keys $ids->%*) { - my $scfg = $ids->{$sid}; - next if !$scfg->{path}; - my $plugin = PVE::Storage::Plugin->lookup($scfg->{type}); + my $parse_volid_from_file_path = sub { + my ($plugin, $sid, $scfg) = @_; # FIXME: Call plugin_get_vtype_subdir() instead of $plugin->get_subdir() # on the next APIAGE reset. my $imagedir = $plugin->get_subdir($scfg, 'images'); my $isodir = $plugin->get_subdir($scfg, 'iso'); @@ -789,10 +787,21 @@ sub path_to_volume_id { if ($path =~ m!^\Q$importdir\E/(${SAFE_CHAR_CLASS_RE}+${IMPORT_EXT_RE_1})$!) { my $name = $1; return ('import', "$sid:import/$name"); } + + return (''); + }; + + for my $sid (keys $ids->%*) { + my $scfg = $ids->{$sid}; + next if !$scfg->{path}; + my $plugin = PVE::Storage::Plugin->lookup($scfg->{type}); + + my ($vtype, $volid) = $parse_volid_from_file_path->($plugin, $sid, $scfg); + return ($vtype, $volid) if $vtype; } # can't map path to volume id return (''); } -- 2.47.3