[pve-devel] [PATCH storage 4/6] migrate: snapshot parameter for incremental transfer

Wolfgang Bumiller w.bumiller at proxmox.com
Thu May 11 09:36:18 CEST 2017


---
The previous patch dropped the new incremental case added by the
replication patches. Figuring this out is now the caller's job.

Currently if the base snapshot doesn't exist this (export/zfs send) will
error out, but note that when more cases (read: more storage types with
different capabilities) switch to import/export this parameter may be
ignored by some cases.

 PVE/Storage.pm | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/PVE/Storage.pm b/PVE/Storage.pm
index 08e9ffd..09a1366 100755
--- a/PVE/Storage.pm
+++ b/PVE/Storage.pm
@@ -559,7 +559,7 @@ sub abs_filesystem_path {
 }
 
 sub storage_migrate {
-    my ($cfg, $volid, $target_host, $target_storeid, $target_volname) = @_;
+    my ($cfg, $volid, $target_host, $target_storeid, $target_volname, $base_snapshot) = @_;
 
     my ($storeid, $volname) = parse_volume_id($volid);
     $target_volname = $volname if !$target_volname;
@@ -580,10 +580,17 @@ sub storage_migrate {
 
     local $ENV{RSYNC_RSH} = $ssh;
 
+    my $no_incremental = sub {
+	my ($type) = @_;
+	die "incremental migration not supported on storage type $type\n"
+	    if defined($base_snapshot);
+    };
+
     # only implemented for file system based storage
     if ($scfg->{path}) {
-	if ($tcfg->{path}) {
+	$no_incremental->($scfg->{type});
 
+	if ($tcfg->{path}) {
 	    my $src_plugin = PVE::Storage::Plugin->lookup($scfg->{type});
 	    my $dst_plugin = PVE::Storage::Plugin->lookup($tcfg->{type});
 	    my $src = $src_plugin->path($scfg, $volname, $storeid);
@@ -656,6 +663,12 @@ sub storage_migrate {
 	    my $recv = ['ssh', "root\@$target_host", '--', 'pvesm', 'import', $volid, 'zfs', '-', '-with-snapshots', '1'];
 	    my $cleanup_target = ['ssh', "root\@$target_host", '--', 'pvesm', 'delsnapshot', $volid, '__migration__'];
 
+	    if (defined($base_snapshot)) {
+		# Check if the snapshot exists on the remote side:
+		push @$send, '-snapshot', $base_snapshot;
+		push @$recv, '-base', $base_snapshot;
+	    }
+
 	    volume_snapshot($cfg, $volid, '__migration__');
 	    eval{
 		run_command([$send, $recv]);
@@ -672,6 +685,7 @@ sub storage_migrate {
  	}
 
     } elsif ($scfg->{type} eq 'lvmthin' || $scfg->{type} eq 'lvm') {
+	$no_incremental->($scfg->{type});
 
 	if (($scfg->{type} eq $tcfg->{type}) &&
 	    ($tcfg->{type} eq 'lvmthin' || $tcfg->{type} eq 'lvm')) {
-- 
2.11.0





More information about the pve-devel mailing list