[pve-devel] [PATCH storage] btrfs: fix handling of non-images volumes

Fabian Grünbichler f.gruenbichler at proxmox.com
Wed Dec 11 14:48:36 CET 2024


previously, only 'images' returned a format, now other volume types do too, so
differentiate where needed.

reported on the forum: https://forum.proxmox.com/threads/158888/

Signed-off-by: Fabian Grünbichler <f.gruenbichler at proxmox.com>
---
 src/PVE/Storage/BTRFSPlugin.pm | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/PVE/Storage/BTRFSPlugin.pm b/src/PVE/Storage/BTRFSPlugin.pm
index def51ef..cadd9d1 100644
--- a/src/PVE/Storage/BTRFSPlugin.pm
+++ b/src/PVE/Storage/BTRFSPlugin.pm
@@ -196,13 +196,13 @@ sub filesystem_path {
 
     $path .= "/$vmid" if $vtype eq 'images';
 
-    if (defined($format) && $format eq 'raw') {
+    if ($vtype eq 'images' && defined($format) && $format eq 'raw') {
 	my $dir = raw_name_to_dir($name);
 	if ($snapname) {
 	    $dir .= "\@$snapname";
 	}
 	$path .= "/$dir/disk.raw";
-    } elsif (defined($format) && $format eq 'subvol') {
+    } elsif ($vtype eq 'images' && defined($format) && $format eq 'subvol') {
 	$path .= "/$name";
 	if ($snapname) {
 	    $path .= "\@$snapname";
@@ -422,10 +422,10 @@ my sub foreach_subvol : prototype($$) {
 sub free_image {
     my ($class, $storeid, $scfg, $volname, $isBase, $_format) = @_;
 
-    my (undef, undef, $vmid, undef, undef, undef, $format) =
+    my ($vtype, undef, $vmid, undef, undef, undef, $format) =
 	$class->parse_volname($volname);
 
-    if (!defined($format) || ($format ne 'subvol' && $format ne 'raw')) {
+    if (!defined($format) || $vtype ne 'images' || ($format ne 'subvol' && $format ne 'raw')) {
 	return $class->SUPER::free_image($storeid, $scfg, $volname, $isBase, $_format);
     }
 
-- 
2.39.5





More information about the pve-devel mailing list