mirror: Go through ready -> complete process for 0 len image
When mirroring or active committing a zero length image, BLOCK_JOB_READY is not reported now, instead the job completes because we short circuit the mirror job loop. This is inconsistent with non-zero length images, and only confuses management software. Let's do the same thing when seeing a 0-length image: report ready immediately; wait for block-job-cancel or block-job-complete; clear the cancel flag as existing non-zero image synced case (cancelled after ready); then jump to the exit. Reported-by: Eric Blake <eblake@redhat.com> Signed-off-by: Fam Zheng <famz@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
dc71ce45de
commit
9e48b02540
@ -324,9 +324,18 @@ static void coroutine_fn mirror_run(void *opaque)
|
|||||||
}
|
}
|
||||||
|
|
||||||
s->common.len = bdrv_getlength(bs);
|
s->common.len = bdrv_getlength(bs);
|
||||||
if (s->common.len <= 0) {
|
if (s->common.len < 0) {
|
||||||
ret = s->common.len;
|
ret = s->common.len;
|
||||||
goto immediate_exit;
|
goto immediate_exit;
|
||||||
|
} else if (s->common.len == 0) {
|
||||||
|
/* Report BLOCK_JOB_READY and wait for complete. */
|
||||||
|
block_job_event_ready(&s->common);
|
||||||
|
s->synced = true;
|
||||||
|
while (!block_job_is_cancelled(&s->common) && !s->should_complete) {
|
||||||
|
block_job_yield(&s->common);
|
||||||
|
}
|
||||||
|
s->common.cancelled = false;
|
||||||
|
goto immediate_exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
length = DIV_ROUND_UP(s->common.len, s->granularity);
|
length = DIV_ROUND_UP(s->common.len, s->granularity);
|
||||||
|
Loading…
Reference in New Issue
Block a user