We found that when doing drive mirror to a low speed shared storage, if there was heavy BLK IO write workload in VM after the 'ready' event, drive mirror block job can't be canceled immediately, it would keep running until the heavy BLK IO workload stopped in the VM. This patch fixed this issue.
Cc: Paolo Bonzini <[email protected]> Cc: Jeff Cody <[email protected]> Cc: Kevin Wolf <[email protected]> Cc: Max Reitz <[email protected]> Signed-off-by: Huaitong Han <[email protected]> Signed-off-by: Liang Li <[email protected]> --- block/mirror.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/block/mirror.c b/block/mirror.c index c9badc1..3bc49a5 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -869,11 +869,9 @@ static void coroutine_fn mirror_run(void *opaque) ret = 0; trace_mirror_before_sleep(s, cnt, s->synced, delay_ns); - if (!s->synced) { - block_job_sleep_ns(&s->common, delay_ns); - if (block_job_is_cancelled(&s->common)) { - break; - } + + if (block_job_is_cancelled(&s->common)) { + break; } else if (!should_complete) { delay_ns = (s->in_flight == 0 && cnt == 0 ? SLICE_TIME : 0); block_job_sleep_ns(&s->common, delay_ns); @@ -887,7 +885,7 @@ immediate_exit: * or it was cancelled prematurely so that we do not guarantee that * the target is a copy of the source. */ - assert(ret < 0 || (!s->synced && block_job_is_cancelled(&s->common))); + assert(ret < 0 || block_job_is_cancelled(&s->common)); assert(need_drain); mirror_wait_for_all_io(s); } -- 1.8.3.1
