[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-block] [Qemu-devel] [PATCH for-2.9-rc5 v3] block: Drain BH in
From: |
Fam Zheng |
Subject: |
Re: [Qemu-block] [Qemu-devel] [PATCH for-2.9-rc5 v3] block: Drain BH in bdrv_drained_begin |
Date: |
Tue, 18 Apr 2017 21:46:27 +0800 |
User-agent: |
Mutt/1.8.0 (2017-02-23) |
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