migrate: implement rate limiting
Note that it does not apply to the local 'mkdir && cp' case.
This commit is contained in:
committed by
Dietmar Maurer
parent
9dc3d2ff40
commit
01f7e902e9
@ -525,7 +525,7 @@ sub abs_filesystem_path {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sub storage_migrate {
|
sub storage_migrate {
|
||||||
my ($cfg, $volid, $target_sshinfo, $target_storeid, $target_volname, $base_snapshot, $snapshot) = @_;
|
my ($cfg, $volid, $target_sshinfo, $target_storeid, $target_volname, $base_snapshot, $snapshot, $ratelimit_bps) = @_;
|
||||||
|
|
||||||
my ($storeid, $volname) = parse_volume_id($volid);
|
my ($storeid, $volname) = parse_volume_id($volid);
|
||||||
$target_volname = $volname if !$target_volname;
|
$target_volname = $volname if !$target_volname;
|
||||||
@ -557,6 +557,9 @@ sub storage_migrate {
|
|||||||
if defined($snapshot);
|
if defined($snapshot);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
my @cstream = ([ '/usr/bin/cstream', '-t', $ratelimit_bps ])
|
||||||
|
if defined($ratelimit_bps);
|
||||||
|
|
||||||
# only implemented for file system based storage
|
# only implemented for file system based storage
|
||||||
if ($scfg->{path}) {
|
if ($scfg->{path}) {
|
||||||
$no_incremental->($scfg->{type});
|
$no_incremental->($scfg->{type});
|
||||||
@ -589,12 +592,15 @@ sub storage_migrate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
my $cmd;
|
my $cmd;
|
||||||
|
my @bwlimit = ("--bwlimit=${ratelimit_bps}b") if defined($ratelimit_bps);
|
||||||
if ($format eq 'subvol') {
|
if ($format eq 'subvol') {
|
||||||
$cmd = ['/usr/bin/rsync', '--progress', '-X', '-A', '--numeric-ids',
|
$cmd = ['/usr/bin/rsync', '--progress', '-X', '-A', '--numeric-ids',
|
||||||
'-aH', '--delete', '--no-whole-file', '--inplace',
|
'-aH', '--delete', '--no-whole-file', '--inplace',
|
||||||
'--one-file-system', "$src/", "[root\@${target_host}]:$dst"];
|
'--one-file-system', @bwlimit,
|
||||||
|
"$src/", "[root\@${target_host}]:$dst"];
|
||||||
} else {
|
} else {
|
||||||
$cmd = ['/usr/bin/rsync', '--progress', '--sparse', '--whole-file',
|
$cmd = ['/usr/bin/rsync', '--progress', '--sparse', '--whole-file',
|
||||||
|
@bwlimit,
|
||||||
$src, "[root\@${target_host}]:$dst"];
|
$src, "[root\@${target_host}]:$dst"];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -653,7 +659,7 @@ sub storage_migrate {
|
|||||||
|
|
||||||
volume_snapshot($cfg, $volid, $snapshot) if $migration_snapshot;
|
volume_snapshot($cfg, $volid, $snapshot) if $migration_snapshot;
|
||||||
eval {
|
eval {
|
||||||
run_command([$send, $recv]);
|
run_command([$send, @cstream, $recv]);
|
||||||
};
|
};
|
||||||
my $err = $@;
|
my $err = $@;
|
||||||
warn "send/receive failed, cleaning up snapshot(s)..\n" if $err;
|
warn "send/receive failed, cleaning up snapshot(s)..\n" if $err;
|
||||||
@ -684,11 +690,11 @@ sub storage_migrate {
|
|||||||
|
|
||||||
eval {
|
eval {
|
||||||
if ($tcfg->{type} eq 'lvmthin') {
|
if ($tcfg->{type} eq 'lvmthin') {
|
||||||
run_command([["dd", "if=$src", "bs=4k"],[@$ssh,
|
run_command([["dd", "if=$src", "bs=4k"], @cstream,
|
||||||
"dd", 'conv=sparse', "of=$dst", "bs=4k"]]);
|
[@$ssh, "dd", 'conv=sparse', "of=$dst", "bs=4k"]]);
|
||||||
} else {
|
} else {
|
||||||
run_command([["dd", "if=$src", "bs=4k"],[@$ssh,
|
run_command([["dd", "if=$src", "bs=4k"], @cstream,
|
||||||
"dd", "of=$dst", "bs=4k"]]);
|
[@$ssh, "dd", "of=$dst", "bs=4k"]]);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if (my $err = $@) {
|
if (my $err = $@) {
|
||||||
|
|||||||
Reference in New Issue
Block a user