storage_migrate_snapshot: skip for btrfs without snapshots

this allows migrating from btrfs to other raw+size accepting storages,
provided no snapshots exist.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
This commit is contained in:
Fabian Grünbichler
2022-02-09 14:07:48 +01:00
committed by Thomas Lamprecht
parent db3d1ef163
commit 686b07376f

View File

@ -645,10 +645,10 @@ my $volname_for_storage = sub {
# whether a migration snapshot is needed for a given storage # whether a migration snapshot is needed for a given storage
sub storage_migrate_snapshot { sub storage_migrate_snapshot {
my ($cfg, $storeid) = @_; my ($cfg, $storeid, $existing_snapshots) = @_;
my $scfg = storage_config($cfg, $storeid); my $scfg = storage_config($cfg, $storeid);
return $scfg->{type} eq 'zfspool' || $scfg->{type} eq 'btrfs'; return $scfg->{type} eq 'zfspool' || ($scfg->{type} eq 'btrfs' && $existing_snapshots);
} }
sub storage_migrate { sub storage_migrate {
@ -696,7 +696,7 @@ sub storage_migrate {
my $migration_snapshot; my $migration_snapshot;
if (!defined($snapshot)) { if (!defined($snapshot)) {
$migration_snapshot = storage_migrate_snapshot($cfg, $storeid); $migration_snapshot = storage_migrate_snapshot($cfg, $storeid, $opts->{with_snapshots});
$snapshot = '__migration__' if $migration_snapshot; $snapshot = '__migration__' if $migration_snapshot;
} }