From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58816) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YdHId-000616-4G for qemu-devel@nongnu.org; Wed, 01 Apr 2015 07:59:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YdHIZ-0004In-Jv for qemu-devel@nongnu.org; Wed, 01 Apr 2015 07:59:11 -0400 Date: Wed, 1 Apr 2015 12:59:01 +0100 From: Stefan Hajnoczi Message-ID: <20150401115901.GB7625@stefanha-thinkpad.redhat.com> References: <1427863341-7156-1-git-send-email-wu.wubin@huawei.com> <20150401081932.GA2777@fam-t430.nay.redhat.com> <551BB123.9050909@huawei.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="qlTNgmc+xy1dBmNv" Content-Disposition: inline In-Reply-To: <551BB123.9050909@huawei.com> Subject: Re: [Qemu-devel] [Qemu-block] [PATCH] mirror: hold aio_context before bdrv_drain List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Bin Wu Cc: qemu-block@nongnu.org, Fam Zheng , qemu-devel@nongnu.org, stefanha@redhat.com --qlTNgmc+xy1dBmNv Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Apr 01, 2015 at 04:49:39PM +0800, Bin Wu wrote: >=20 > On 2015/4/1 16:19, Fam Zheng wrote: > > On Wed, 04/01 12:42, Bin Wu wrote: > >> From: Bin Wu > >=20 > > What's the issue are you fixing? I think the coroutine already is runni= ng in > > the AioContext of bs. > >=20 > > Fam > >=20 > In the current implementation of bdrv_drain, it should be placed in a cri= tical > section as suggested in the comments above the function: "Note that unlike > bdrv_drain_all(), the caller must hold the BlockDriverState AioContext". >=20 > 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 scop= e 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 --qlTNgmc+xy1dBmNv Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEcBAEBAgAGBQJVG92FAAoJEJykq7OBq3PIg5YH/2+juwuiCnFgh50wHp3eOtcV GXv9cFEq52wdYr03DEeTrvyTDFkz3TYR4et+MYIWyGZ2CR1Cj91dvgBpUhANLzpU PFKZJzmxitKP1dhEuUXzNJUmX6ejBQzN/9kvouULAjIYa/oJfkjs6u5VeTr3abs5 PGCk4iAidhuoDd8fV78ehciP1DbweEvG7lA+UNQ+1czGF8+g54Vve41fK3mDKNIi f0eV6czBNeuz69ikRAx/FKgG6AsZNofQj08YX7kgdUoUD+5mFcn12j5JVd2M9tos egSAkrsM22KslI4x2mbllQotgFQyAvx8me/1l/dY9I47hkRvXOEKA+3Yu2oX1U8= =NvVI -----END PGP SIGNATURE----- --qlTNgmc+xy1dBmNv--