From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53871) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a48HI-0002mS-Uv for qemu-devel@nongnu.org; Wed, 02 Dec 2015 09:21:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a48HF-0006gy-Q3 for qemu-devel@nongnu.org; Wed, 02 Dec 2015 09:21:04 -0500 Date: Wed, 2 Dec 2015 09:20:48 -0500 From: Jeff Cody Message-ID: <20151202142048.GE2645@localhost.localdomain> References: <1448245684-13918-1-git-send-email-famz@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1448245684-13918-1-git-send-email-famz@redhat.com> Subject: Re: [Qemu-devel] [PATCH] mirror: Quiesce source during "mirror_exit" List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Fam Zheng Cc: Kevin Wolf , pbonzini@redhat.com, qemu-devel@nongnu.org, qemu-block@nongnu.org On Mon, Nov 23, 2015 at 10:28:04AM +0800, Fam Zheng wrote: > 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. > > Signed-off-by: Fam Zheng > --- > block/mirror.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/block/mirror.c b/block/mirror.c > index 52c9abf..0e8f556 100644 > --- a/block/mirror.c > +++ b/block/mirror.c > @@ -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); > } > > -- > 2.4.3 > Thanks, applied to my block branch: git://github.com/codyprime/qemu-kvm-jtc.git block