qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Fam Zheng <famz@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: qemu-devel@nongnu.org, Kevin Wolf <kwolf@redhat.com>,
	jcody@redhat.com, Stefan Hajnoczi <stefanha@redhat.com>,
	qemu-block@nongnu.org, Max Reitz <mreitz@redhat.com>
Subject: Re: [Qemu-devel] [PATCH for-2.9-rc5 v3] block: Drain BH in bdrv_drained_begin
Date: Tue, 18 Apr 2017 21:46:27 +0800	[thread overview]
Message-ID: <20170418134627.GC490@lemon.lan> (raw)
In-Reply-To: <3b51de74-0d1b-ebae-1b98-fa74d028c982@redhat.com>

On Tue, 04/18 14:36, Paolo Bonzini wrote:
> 
> 
> On 18/04/2017 12:39, Fam Zheng wrote:
> > +    QLIST_FOREACH_SAFE(child, &bs->children, next, tmp) {
> > +        BlockDriverState *bs = child->bs;
> > +        assert(bs->refcnt > 0);
> > +        bdrv_ref(bs);
> > +        waited |= bdrv_drain_recurse(bs);
> > +        bdrv_unref(bs);
> >      }
> 
> I think this accesses global state that is not protected by the
> AioContext lock?

Good catch! If called from IOThread, this bdrv_unref is simply wrong, although
in practice it cannot delete bs because of the reference held by the owning
device.

It may be better to wrap the bdrv_ref/bdrv_unref calls with

     if (qemu_get_current_aio_context() == qemu_get_aio_context())

because only the main loop needs it.

Will make this hunk a separate patch in v4.

Fam

      reply	other threads:[~2017-04-18 13:46 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-18 10:39 [Qemu-devel] [PATCH for-2.9-rc5 v3] block: Drain BH in bdrv_drained_begin Fam Zheng
2017-04-18 10:53 ` Kevin Wolf
2017-04-18 11:21 ` Jeff Cody
2017-04-18 12:36 ` Paolo Bonzini
2017-04-18 13:46   ` Fam Zheng [this message]

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=20170418134627.GC490@lemon.lan \
    --to=famz@redhat.com \
    --cc=jcody@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=pbonzini@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).