block-copy: let ratelimit handle a speed of 0

Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
Message-Id: <20210614081130.22134-3-eesposit@redhat.com>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
This commit is contained in:
Paolo Bonzini 2021-06-14 10:11:27 +02:00 committed by Vladimir Sementsov-Ogievskiy
parent 720507ed95
commit ca657c99e6

View File

@ -114,7 +114,6 @@ typedef struct BlockCopyState {
SharedResource *mem; SharedResource *mem;
uint64_t speed;
RateLimit rate_limit; RateLimit rate_limit;
} BlockCopyState; } BlockCopyState;
@ -647,7 +646,6 @@ block_copy_dirty_clusters(BlockCopyCallState *call_state)
task->copy_range = false; task->copy_range = false;
} }
if (s->speed) {
if (!call_state->ignore_ratelimit) { if (!call_state->ignore_ratelimit) {
uint64_t ns = ratelimit_calculate_delay(&s->rate_limit, 0); uint64_t ns = ratelimit_calculate_delay(&s->rate_limit, 0);
if (ns > 0) { if (ns > 0) {
@ -660,7 +658,6 @@ block_copy_dirty_clusters(BlockCopyCallState *call_state)
} }
ratelimit_calculate_delay(&s->rate_limit, task->bytes); ratelimit_calculate_delay(&s->rate_limit, task->bytes);
}
trace_block_copy_process(s, task->offset); trace_block_copy_process(s, task->offset);
@ -853,10 +850,7 @@ void block_copy_set_skip_unallocated(BlockCopyState *s, bool skip)
void block_copy_set_speed(BlockCopyState *s, uint64_t speed) void block_copy_set_speed(BlockCopyState *s, uint64_t speed)
{ {
s->speed = speed;
if (speed > 0) {
ratelimit_set_speed(&s->rate_limit, speed, BLOCK_COPY_SLICE_TIME); ratelimit_set_speed(&s->rate_limit, speed, BLOCK_COPY_SLICE_TIME);
}
/* /*
* Note: it's good to kick all call states from here, but it should be done * Note: it's good to kick all call states from here, but it should be done