[pve-devel] [PATCH storage v3] fix #4272: btrfs: add rename feature

Maximiliano Sandoval m.sandoval at proxmox.com
Fri Jul 5 15:14:04 CEST 2024


Aaron Lauterer <a.lauterer at proxmox.com> writes:

> gave it a try and it does what it should.
> by enabling the rename feature only for `raw` we avoid potential pitfalls if we
> encounter a non regular situation on BTRFS. For example, an
> images/{vmid}/vm-{vmid}-disk-X.qcow2 file directly instead of the
> images/{vmid}/vm-{vmid}-disk-X/disk.raw as is the way the BTRFS plugin handles
> it in subvolumes.
>
> But if we add the following diff, it seems to handle the case of a qcow2 file in
> the same directory structure just fine:
>
> diff --git a/src/PVE/Storage/BTRFSPlugin.pm b/src/PVE/Storage/BTRFSPlugin.pm
> index 7376ae4..143442c 100644
> --- a/src/PVE/Storage/BTRFSPlugin.pm
> +++ b/src/PVE/Storage/BTRFSPlugin.pm
> @@ -619,7 +619,7 @@ sub volume_has_feature {
>             current => { qcow2 => 1, raw => 1, vmdk => 1 },
>         },
>         rename => {
> -           current => { raw => 1 },
> +           current => { qcow2 => 1, raw => 1},
>         },
>      };
>
> @@ -939,6 +939,10 @@ sub rename_volume {
>
>      my $format = ($class->parse_volname($source_volname))[6];
>
> +    if ($format ne 'raw' && $format ne 'subvol') {
> +       return $class->SUPER::rename_volume($scfg, $storeid, $source_volname,
> $target_vmid, $target_volname);
> +    }
> +
>      my $ppath = $class->filesystem_path($scfg, $source_volname);
>
>      $target_volname = $class->find_free_diskname($storeid, $scfg, $target_vmid,
>     $format, 1)
>
>
> Since we do have that in the other functions (alloc_image, free_image), we might
> want to add it here as well, just to be safe.
>
> If we aren't concerned about this, then consider this:
>
> Reviewed-By: Aaron Lauterer <a.lauterer at proxmox.com>
> Tested-By: Aaron Lauterer <a.lauterer at proxmox.com>

I added your suggestion on v4.

-- 
Maximiliano




More information about the pve-devel mailing list