Message ID | 20171214005953.8898-8-jsnow@redhat.com |
---|---|
State | New |
Headers | show |
Series | blockjob: refactor mirror_throttle | expand |
On 14/12/2017 01:59, John Snow wrote: > Signed-off-by: John Snow <jsnow@redhat.com> > --- > block/backup.c | 11 ++++++----- > 1 file changed, 6 insertions(+), 5 deletions(-) > > diff --git a/block/backup.c b/block/backup.c > index d71b25c017..a5ede5f643 100644 > --- a/block/backup.c > +++ b/block/backup.c > @@ -334,6 +334,8 @@ static void backup_complete(BlockJob *job, void *opaque) > > static bool coroutine_fn yield_and_check(BackupBlockJob *job) > { > + uint64_t delay_ns = 0; > + > if (block_job_is_cancelled(&job->common)) { > return true; > } > @@ -342,14 +344,13 @@ static bool coroutine_fn yield_and_check(BackupBlockJob *job) > * (without, VM does not reboot) > */ > if (job->common.speed) { > - uint64_t delay_ns = ratelimit_calculate_delay(&job->limit, > - job->bytes_read); > + delay_ns = ratelimit_calculate_delay(&job->limit, > + job->bytes_read); > job->bytes_read = 0; > - block_job_sleep_ns(&job->common, delay_ns); > - } else { > - block_job_sleep_ns(&job->common, 0); > } > > + block_job_throttle(&job->common, delay_ns); > + > if (block_job_is_cancelled(&job->common)) { > return true; > } > This one is. :) Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
On Wed, Dec 13, 2017 at 07:59:53PM -0500, John Snow wrote: > Signed-off-by: John Snow <jsnow@redhat.com> > --- > block/backup.c | 11 ++++++----- > 1 file changed, 6 insertions(+), 5 deletions(-) Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
diff --git a/block/backup.c b/block/backup.c index d71b25c017..a5ede5f643 100644 --- a/block/backup.c +++ b/block/backup.c @@ -334,6 +334,8 @@ static void backup_complete(BlockJob *job, void *opaque) static bool coroutine_fn yield_and_check(BackupBlockJob *job) { + uint64_t delay_ns = 0; + if (block_job_is_cancelled(&job->common)) { return true; } @@ -342,14 +344,13 @@ static bool coroutine_fn yield_and_check(BackupBlockJob *job) * (without, VM does not reboot) */ if (job->common.speed) { - uint64_t delay_ns = ratelimit_calculate_delay(&job->limit, - job->bytes_read); + delay_ns = ratelimit_calculate_delay(&job->limit, + job->bytes_read); job->bytes_read = 0; - block_job_sleep_ns(&job->common, delay_ns); - } else { - block_job_sleep_ns(&job->common, 0); } + block_job_throttle(&job->common, delay_ns); + if (block_job_is_cancelled(&job->common)) { return true; }
Signed-off-by: John Snow <jsnow@redhat.com> --- block/backup.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)