[pve-devel] [PATCH v3 storage 2/4] storage_migrate: pull out snapshot decision
Fabian Ebner
f.ebner at proxmox.com
Wed Jan 5 10:00:47 CET 2022
Am 22.12.21 um 14:52 schrieb Fabian Grünbichler:
> into new top-level helper for re-use with remote migration.
>
> Signed-off-by: Fabian Grünbichler <f.gruenbichler at proxmox.com>
> ---
> new in v3
>
> PVE/Storage.pm | 14 ++++++++++----
> 1 file changed, 10 insertions(+), 4 deletions(-)
>
> diff --git a/PVE/Storage.pm b/PVE/Storage.pm
> index 05be3dd..4f3a44a 100755
> --- a/PVE/Storage.pm
> +++ b/PVE/Storage.pm
> @@ -643,6 +643,14 @@ my $volname_for_storage = sub {
> }
> };
>
> +# whether a migration snapshot is needed for a given storage
> +sub storage_migrate_snapshot {
> + my ($cfg, $storeid) = @_;
> + my $scfg = storage_config($cfg, $storeid);
> +
> + return $scfg->{type} eq 'zfspool' || $scfg->{type} eq 'btrfs';
> +}
> +
> sub storage_migrate {
> my ($cfg, $volid, $target_sshinfo, $target_storeid, $opts, $logfunc) = @_;
>
> @@ -688,10 +696,8 @@ sub storage_migrate {
>
> my $migration_snapshot;
> if (!defined($snapshot)) {
> - if ($scfg->{type} eq 'zfspool' || $scfg->{type} eq 'btrfs') {
> - $migration_snapshot = 1;
> - $snapshot = '__migration__';
> - }
> + $migration_snapshot = storage_migrate_snapshot->($cfg, $target_storeid);
The call is wrong, because of the ->
And why base the decision on the target storage rather than keeping it
based on the source storage? That breaks migration from e.g. lvm-thin to
btrfs, because it now tries to use a snapshot and doesn't find any
common transfer format anymore.
> + $snapshot = '__migration__' if $migration_snapshot;
> }
>
> my @formats = volume_transfer_formats($cfg, $volid, $target_volid, $snapshot, $base_snapshot, $with_snapshots);
More information about the pve-devel
mailing list