* [Qemu-devel] [PATCH] mirror: hold aio_context before bdrv_drain
@ 2015-04-01 4:42 Bin Wu
2015-04-01 8:19 ` Fam Zheng
0 siblings, 1 reply; 5+ messages in thread
From: Bin Wu @ 2015-04-01 4:42 UTC (permalink / raw)
To: qemu-devel, qemu-block, jcody, stefanha; +Cc: Bin Wu
From: Bin Wu <wu.wubin@huawei.com>
Signed-off-by: Bin Wu <wu.wubin@huawei.com>
---
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
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH] mirror: hold aio_context before bdrv_drain
2015-04-01 4:42 [Qemu-devel] [PATCH] mirror: hold aio_context before bdrv_drain Bin Wu
@ 2015-04-01 8:19 ` Fam Zheng
2015-04-01 8:49 ` Bin Wu
0 siblings, 1 reply; 5+ messages in thread
From: Fam Zheng @ 2015-04-01 8:19 UTC (permalink / raw)
To: Bin Wu; +Cc: jcody, stefanha, qemu-devel, qemu-block
On Wed, 04/01 12:42, Bin Wu wrote:
> From: Bin Wu <wu.wubin@huawei.com>
What's the issue are you fixing? I think the coroutine already is running in
the AioContext of bs.
Fam
>
> Signed-off-by: Bin Wu <wu.wubin@huawei.com>
> ---
> 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
>
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH] mirror: hold aio_context before bdrv_drain
2015-04-01 8:19 ` Fam Zheng
@ 2015-04-01 8:49 ` Bin Wu
2015-04-01 11:59 ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
0 siblings, 1 reply; 5+ messages in thread
From: Bin Wu @ 2015-04-01 8:49 UTC (permalink / raw)
To: Fam Zheng; +Cc: jcody, stefanha, qemu-devel, qemu-block
On 2015/4/1 16:19, Fam Zheng wrote:
> On Wed, 04/01 12:42, Bin Wu wrote:
>> From: Bin Wu <wu.wubin@huawei.com>
>
> 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 <wu.wubin@huawei.com>
>> ---
>> 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
>>
>>
>>
>
> .
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [Qemu-block] [PATCH] mirror: hold aio_context before bdrv_drain
2015-04-01 8:49 ` Bin Wu
@ 2015-04-01 11:59 ` Stefan Hajnoczi
2015-04-02 0:40 ` Bin Wu
0 siblings, 1 reply; 5+ messages in thread
From: Stefan Hajnoczi @ 2015-04-01 11:59 UTC (permalink / raw)
To: Bin Wu; +Cc: qemu-block, Fam Zheng, qemu-devel, stefanha
[-- Attachment #1: Type: text/plain, Size: 1244 bytes --]
On Wed, Apr 01, 2015 at 04:49:39PM +0800, Bin Wu wrote:
>
> On 2015/4/1 16:19, Fam Zheng wrote:
> > On Wed, 04/01 12:42, Bin Wu wrote:
> >> From: Bin Wu <wu.wubin@huawei.com>
> >
> > 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.
There are 3 possibilities:
1. qmp_drive_mirror() under QEMU main loop thread. AioContext is held.
2. IOThread aio_poll(). AioContext is held.
3. QEMU main loop thread when IOThread (dataplane) is not used. Here
the AioContext is the global qemu_aio_context. We don't need to
acquire it explicitly, we're protected by the global mutex.
If #3 was a problem then virtio-blk.c's bdrv_aio_writev() would also be
a problem, for example.
This patch is unnecessary.
Stefan
[-- Attachment #2: Type: application/pgp-signature, Size: 473 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [Qemu-block] [PATCH] mirror: hold aio_context before bdrv_drain
2015-04-01 11:59 ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
@ 2015-04-02 0:40 ` Bin Wu
0 siblings, 0 replies; 5+ messages in thread
From: Bin Wu @ 2015-04-02 0:40 UTC (permalink / raw)
To: Stefan Hajnoczi; +Cc: qemu-block, Fam Zheng, qemu-devel, stefanha
On 2015/4/1 19:59, Stefan Hajnoczi wrote:
> On Wed, Apr 01, 2015 at 04:49:39PM +0800, Bin Wu wrote:
>>
>> On 2015/4/1 16:19, Fam Zheng wrote:
>>> On Wed, 04/01 12:42, Bin Wu wrote:
>>>> From: Bin Wu <wu.wubin@huawei.com>
>>>
>>> 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.
>
> There are 3 possibilities:
>
> 1. qmp_drive_mirror() under QEMU main loop thread. AioContext is held.
>
> 2. IOThread aio_poll(). AioContext is held.
>
> 3. QEMU main loop thread when IOThread (dataplane) is not used. Here
> the AioContext is the global qemu_aio_context. We don't need to
> acquire it explicitly, we're protected by the global mutex.
>
> If #3 was a problem then virtio-blk.c's bdrv_aio_writev() would also be
> a problem, for example.
>
> This patch is unnecessary.
>
> Stefan
>
OK, I see. Thanks
--
Bin Wu
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2015-04-02 0:43 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-04-01 4:42 [Qemu-devel] [PATCH] mirror: hold aio_context before bdrv_drain Bin Wu
2015-04-01 8:19 ` Fam Zheng
2015-04-01 8:49 ` Bin Wu
2015-04-01 11:59 ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
2015-04-02 0:40 ` Bin Wu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).