qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Denis V. Lunev" <den@openvz.org>
To: Stefan Hajnoczi <stefanha@redhat.com>, qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
	Markus Armbruster <armbru@redhat.com>,
	qemu-block@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] blockdev: acquire AioContext in hmp_commit()
Date: Sun, 1 Nov 2015 20:50:36 +0300	[thread overview]
Message-ID: <563650EC.2040307@openvz.org> (raw)
In-Reply-To: <1446220661-18792-1-git-send-email-stefanha@redhat.com>

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

  parent reply	other threads:[~2015-11-01 17:50 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2015-11-02 13:29   ` [Qemu-devel] " Stefan Hajnoczi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=563650EC.2040307@openvz.org \
    --to=den@openvz.org \
    --cc=armbru@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).