All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] blockdev: acquire AioContext in hmp_commit()
@ 2015-10-30 15:57 Stefan Hajnoczi
  2015-10-30 16:01 ` [Qemu-devel] [Qemu-block] " Jeff Cody
  2015-11-01 17:50 ` [Qemu-devel] " Denis V. Lunev
  0 siblings, 2 replies; 4+ messages in thread
From: Stefan Hajnoczi @ 2015-10-30 15:57 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, Denis V. Lunev, Stefan Hajnoczi, Markus Armbruster,
	qemu-block

This one slipped through.  Although we acquire AioContext when
committing all devices we don't for just a single device.

AioContext must be acquired before calling bdrv_*() functions to
synchronize access with other threads that may be using the AioContext.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 blockdev.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/blockdev.c b/blockdev.c
index 18712d2..d611779 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -1120,6 +1120,9 @@ void hmp_commit(Monitor *mon, const QDict *qdict)
     if (!strcmp(device, "all")) {
         ret = bdrv_commit_all();
     } else {
+        BlockDriverState *bs;
+        AioContext *aio_context;
+
         blk = blk_by_name(device);
         if (!blk) {
             monitor_printf(mon, "Device '%s' not found\n", device);
@@ -1129,7 +1132,14 @@ void hmp_commit(Monitor *mon, const QDict *qdict)
             monitor_printf(mon, "Device '%s' has no medium\n", device);
             return;
         }
-        ret = bdrv_commit(blk_bs(blk));
+
+        bs = blk_bs(blk);
+        aio_context = bdrv_get_aio_context(bs);
+        aio_context_acquire(aio_context);
+
+        ret = bdrv_commit(bs);
+
+        aio_context_release(aio_context);
     }
     if (ret < 0) {
         monitor_printf(mon, "'commit' error for '%s': %s\n", device,
-- 
2.4.3

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [Qemu-block] [PATCH] blockdev: acquire AioContext in hmp_commit()
  2015-10-30 15:57 [Qemu-devel] [PATCH] blockdev: acquire AioContext in hmp_commit() Stefan Hajnoczi
@ 2015-10-30 16:01 ` Jeff Cody
  2015-11-01 17:50 ` [Qemu-devel] " Denis V. Lunev
  1 sibling, 0 replies; 4+ messages in thread
From: Jeff Cody @ 2015-10-30 16:01 UTC (permalink / raw)
  To: Stefan Hajnoczi
  Cc: Kevin Wolf, Denis V. Lunev, qemu-devel, qemu-block, Markus Armbruster

On Fri, Oct 30, 2015 at 03:57:41PM +0000, Stefan Hajnoczi wrote:
> This one slipped through.  Although we acquire AioContext when
> committing all devices we don't for just a single device.
> 
> AioContext must be acquired before calling bdrv_*() functions to
> synchronize access with other threads that may be using the AioContext.
> 
> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> ---
>  blockdev.c | 12 +++++++++++-
>  1 file changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/blockdev.c b/blockdev.c
> index 18712d2..d611779 100644
> --- a/blockdev.c
> +++ b/blockdev.c
> @@ -1120,6 +1120,9 @@ void hmp_commit(Monitor *mon, const QDict *qdict)
>      if (!strcmp(device, "all")) {
>          ret = bdrv_commit_all();
>      } else {
> +        BlockDriverState *bs;
> +        AioContext *aio_context;
> +
>          blk = blk_by_name(device);
>          if (!blk) {
>              monitor_printf(mon, "Device '%s' not found\n", device);
> @@ -1129,7 +1132,14 @@ void hmp_commit(Monitor *mon, const QDict *qdict)
>              monitor_printf(mon, "Device '%s' has no medium\n", device);
>              return;
>          }
> -        ret = bdrv_commit(blk_bs(blk));
> +
> +        bs = blk_bs(blk);
> +        aio_context = bdrv_get_aio_context(bs);
> +        aio_context_acquire(aio_context);
> +
> +        ret = bdrv_commit(bs);
> +
> +        aio_context_release(aio_context);
>      }
>      if (ret < 0) {
>          monitor_printf(mon, "'commit' error for '%s': %s\n", device,
> -- 
> 2.4.3
> 
> 

Reviewed-by: Jeff Cody <jcody@redhat.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH] blockdev: acquire AioContext in hmp_commit()
  2015-10-30 15:57 [Qemu-devel] [PATCH] blockdev: acquire AioContext in hmp_commit() Stefan Hajnoczi
  2015-10-30 16:01 ` [Qemu-devel] [Qemu-block] " Jeff Cody
@ 2015-11-01 17:50 ` Denis V. Lunev
  2015-11-02 13:29   ` Stefan Hajnoczi
  1 sibling, 1 reply; 4+ messages in thread
From: Denis V. Lunev @ 2015-11-01 17:50 UTC (permalink / raw)
  To: Stefan Hajnoczi, qemu-devel; +Cc: Kevin Wolf, Markus Armbruster, qemu-block

On 10/30/2015 06:57 PM, Stefan Hajnoczi wrote:
> This one slipped through.  Although we acquire AioContext when
> committing all devices we don't for just a single device.
>
> AioContext must be acquired before calling bdrv_*() functions to
> synchronize access with other threads that may be using the AioContext.
>
> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> ---
>   blockdev.c | 12 +++++++++++-
>   1 file changed, 11 insertions(+), 1 deletion(-)
>
> diff --git a/blockdev.c b/blockdev.c
> index 18712d2..d611779 100644
> --- a/blockdev.c
> +++ b/blockdev.c
> @@ -1120,6 +1120,9 @@ void hmp_commit(Monitor *mon, const QDict *qdict)
>       if (!strcmp(device, "all")) {
>           ret = bdrv_commit_all();
>       } else {
> +        BlockDriverState *bs;
> +        AioContext *aio_context;
> +
>           blk = blk_by_name(device);
>           if (!blk) {
>               monitor_printf(mon, "Device '%s' not found\n", device);
> @@ -1129,7 +1132,14 @@ void hmp_commit(Monitor *mon, const QDict *qdict)
>               monitor_printf(mon, "Device '%s' has no medium\n", device);
>               return;
>           }
> -        ret = bdrv_commit(blk_bs(blk));
> +
> +        bs = blk_bs(blk);
> +        aio_context = bdrv_get_aio_context(bs);
> +        aio_context_acquire(aio_context);
> +
> +        ret = bdrv_commit(bs);
> +
> +        aio_context_release(aio_context);
>       }
>       if (ret < 0) {
>           monitor_printf(mon, "'commit' error for '%s': %s\n", device,
I like it in general, but could you pls wait a bit before pushing
it up. I am working at the moment on a more generic series.
I am going to attach this patch to it to consider the situation
as a whole.

It would be much trickier than my previous one. There are
several other places discovered.

Den

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH] blockdev: acquire AioContext in hmp_commit()
  2015-11-01 17:50 ` [Qemu-devel] " Denis V. Lunev
@ 2015-11-02 13:29   ` Stefan Hajnoczi
  0 siblings, 0 replies; 4+ messages in thread
From: Stefan Hajnoczi @ 2015-11-02 13:29 UTC (permalink / raw)
  To: Denis V. Lunev
  Cc: Kevin Wolf, qemu-block, qemu-devel, Stefan Hajnoczi, Markus Armbruster

[-- Attachment #1: Type: text/plain, Size: 2160 bytes --]

On Sun, Nov 01, 2015 at 08:50:36PM +0300, Denis V. Lunev wrote:
> On 10/30/2015 06:57 PM, Stefan Hajnoczi wrote:
> >This one slipped through.  Although we acquire AioContext when
> >committing all devices we don't for just a single device.
> >
> >AioContext must be acquired before calling bdrv_*() functions to
> >synchronize access with other threads that may be using the AioContext.
> >
> >Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> >---
> >  blockdev.c | 12 +++++++++++-
> >  1 file changed, 11 insertions(+), 1 deletion(-)
> >
> >diff --git a/blockdev.c b/blockdev.c
> >index 18712d2..d611779 100644
> >--- a/blockdev.c
> >+++ b/blockdev.c
> >@@ -1120,6 +1120,9 @@ void hmp_commit(Monitor *mon, const QDict *qdict)
> >      if (!strcmp(device, "all")) {
> >          ret = bdrv_commit_all();
> >      } else {
> >+        BlockDriverState *bs;
> >+        AioContext *aio_context;
> >+
> >          blk = blk_by_name(device);
> >          if (!blk) {
> >              monitor_printf(mon, "Device '%s' not found\n", device);
> >@@ -1129,7 +1132,14 @@ void hmp_commit(Monitor *mon, const QDict *qdict)
> >              monitor_printf(mon, "Device '%s' has no medium\n", device);
> >              return;
> >          }
> >-        ret = bdrv_commit(blk_bs(blk));
> >+
> >+        bs = blk_bs(blk);
> >+        aio_context = bdrv_get_aio_context(bs);
> >+        aio_context_acquire(aio_context);
> >+
> >+        ret = bdrv_commit(bs);
> >+
> >+        aio_context_release(aio_context);
> >      }
> >      if (ret < 0) {
> >          monitor_printf(mon, "'commit' error for '%s': %s\n", device,
> I like it in general, but could you pls wait a bit before pushing
> it up. I am working at the moment on a more generic series.
> I am going to attach this patch to it to consider the situation
> as a whole.
> 
> It would be much trickier than my previous one. There are
> several other places discovered.

Sure.  We need to solve the missing AioContext acquires by hard freeze
(2015-11-12, see http://qemu-project.org/Planning/2.5).  Until then we
can discuss different solutions.

Stefan

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-11-02 13:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-30 15:57 [Qemu-devel] [PATCH] blockdev: acquire AioContext in hmp_commit() Stefan Hajnoczi
2015-10-30 16:01 ` [Qemu-devel] [Qemu-block] " Jeff Cody
2015-11-01 17:50 ` [Qemu-devel] " Denis V. Lunev
2015-11-02 13:29   ` Stefan Hajnoczi

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.