mirror: Quiesce source during "mirror_exit"
PATCH 1/1 mirror: Quiesce source during "mirror_exit"
With dataplane, the ioeventfd events could be dispatched after mirror_run releases the dirty bitmap, but before mirror_exit actually does the device switch, because the iothread will still be running, and it will cause silent data loss.
Fix this by adding a bdrv_drained_begin/end pair around the window, so that no new external request will be handled.
--- block/mirror.c | 4 ++++ 1 file changed, 4 insertions(+)
block/mirror.c +4 -0
@@ -388,6 +388,7 @@ static void mirror_exit(BlockJob *job, void *opaque)bdrv_unref (s->target);block_job_completed (&s->common, data->ret);g_free (data); +bdrv_drained_end (src);bdrv_unref (src); }
@@ -607,6 +608,9 @@ immediate_exit: data =g_malloc (sizeof (*data)); data->ret = ret; +/* Before we switch to target in mirror_exit, make sure data doesn't +* change. */ +bdrv_drained_begin (s->common.bs);block_job_defer_to_main_loop (&s->common, mirror_exit, data); }
Signature · 1 line
2.4.3
Jeff Cody
AppliedQuoted 38 lines · Fam Zheng
With dataplane, the ioeventfd events could be dispatched after
mirror_runreleases the dirty bitmap, but beforemirror_exitactually does the device switch, because the iothread will still be running, and it will cause silent data loss.Fix this by adding a bdrv_drained_begin/end pair around the window, so that no new external request will be handled.
Signed-off-by Fam Zheng <[email protected]>--- block/mirror.c | 4 ++++ 1 file changed, 4 insertions(+)block/mirror.c +4
-0@@ -388,6 +388,7 @@ static void mirror_exit(BlockJob *job, void *opaque)bdrv_unref (s->target);block_job_completed (&s->common, data->ret);g_free (data); +bdrv_drained_end (src);bdrv_unref (src); }@@ -607,6 +608,9 @@ immediate_exit: data =g_malloc (sizeof (*data)); data->ret = ret; +/* Before we switch to target in mirror_exit, make sure data doesn't +* change. */ +bdrv_drained_begin (s->common.bs);block_job_defer_to_main_loop (&s->common, mirror_exit, data); }Signature · 1 line
2.4.3
Thanks, applied to my block branch:
git://github.com/codyprime/qemu-kvm-jtc.git block