From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54540) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YdELn-000392-DC for qemu-devel@nongnu.org; Wed, 01 Apr 2015 04:50:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YdELj-00008p-Ff for qemu-devel@nongnu.org; Wed, 01 Apr 2015 04:50:15 -0400 Message-ID: <551BB123.9050909@huawei.com> Date: Wed, 1 Apr 2015 16:49:39 +0800 From: Bin Wu MIME-Version: 1.0 References: <1427863341-7156-1-git-send-email-wu.wubin@huawei.com> <20150401081932.GA2777@fam-t430.nay.redhat.com> In-Reply-To: <20150401081932.GA2777@fam-t430.nay.redhat.com> Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] mirror: hold aio_context before bdrv_drain List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Fam Zheng Cc: jcody@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org, qemu-block@nongnu.org On 2015/4/1 16:19, Fam Zheng wrote: > On Wed, 04/01 12:42, Bin Wu wrote: >> From: Bin Wu > > What's the issue are you fixing? I think the coroutine already is running in > the AioContext of bs. > > Fam > In the current implementation of bdrv_drain, it should be placed in a critical section as suggested in the comments above the function: "Note that unlike bdrv_drain_all(), the caller must hold the BlockDriverState AioContext". However, the mirror coroutine starting with mirror_run doesn't do this. I just found qmp_drive_mirror protects the AioCentext, but it is out of the scope of the mirror coroutine. Bin >> >> Signed-off-by: Bin Wu >> --- >> block/mirror.c | 2 ++ >> 1 file changed, 2 insertions(+) >> >> diff --git a/block/mirror.c b/block/mirror.c >> index 4056164..08372df 100644 >> --- a/block/mirror.c >> +++ b/block/mirror.c >> @@ -530,7 +530,9 @@ static void coroutine_fn mirror_run(void *opaque) >> * mirror_populate runs. >> */ >> trace_mirror_before_drain(s, cnt); >> + aio_context_acquire(bdrv_get_aio_context(bs)); >> bdrv_drain(bs); >> + aio_context_release(bdrv_get_aio_context(bs)); >> cnt = bdrv_get_dirty_count(bs, s->dirty_bitmap); >> } >> >> -- >> 1.7.12.4 >> >> >> > > . >