]> git.proxmox.com Git - pve-storage.git/commitdiff
btrfs: avoid undef warnings with format
authorFabian Ebner <f.ebner@proxmox.com>
Wed, 8 Sep 2021 11:26:50 +0000 (13:26 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 8 Sep 2021 12:26:12 +0000 (14:26 +0200)
which is only set by parse_volname when the volume is a VM or
container image, but not for other content types.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
PVE/Storage/BTRFSPlugin.pm

index fe4208289661e81f0fb3a9cf296753f508d80afd..a1e5b98c3636c003749310ea117d4edc88acde64 100644 (file)
@@ -180,13 +180,13 @@ sub filesystem_path {
 
     $path .= "/$vmid" if $vtype eq 'images';
 
-    if ($format eq 'raw') {
+    if (defined($format) && $format eq 'raw') {
        my $dir = raw_name_to_dir($name);
        if ($snapname) {
            $dir .= "\@$snapname";
        }
        $path .= "/$dir/disk.raw";
-    } elsif ($format eq 'subvol') {
+    } elsif (defined($format) && $format eq 'subvol') {
        $path .= "/$name";
        if ($snapname) {
            $path .= "\@$snapname";
@@ -409,7 +409,7 @@ sub free_image {
     my (undef, undef, $vmid, undef, undef, undef, $format) =
        $class->parse_volname($volname);
 
-    if ($format ne 'subvol' && $format ne 'raw') {
+    if (!defined($format) || ($format ne 'subvol' && $format ne 'raw')) {
        return PVE::Storage::DirPlugin->free_image($storeid, $scfg, $volname, $isBase, $_format);
     }
 
@@ -465,7 +465,7 @@ sub volume_size_info {
 
     my $format = ($class->parse_volname($volname))[6];
 
-    if ($format eq 'subvol') {
+    if (defined($format) && $format eq 'subvol') {
        my $ctime = (stat($path))[10];
        my ($used, $size) = (0, 0);
        #my ($used, $size) = btrfs_subvol_quota($class, $path); # uses wantarray