From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44805) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XZi08-0000l1-SN for qemu-devel@nongnu.org; Thu, 02 Oct 2014 11:09:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XZhzz-0001eP-R6 for qemu-devel@nongnu.org; Thu, 02 Oct 2014 11:09:04 -0400 Received: from mail-wg0-x22c.google.com ([2a00:1450:400c:c00::22c]:55012) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XZhzz-0001eJ-KV for qemu-devel@nongnu.org; Thu, 02 Oct 2014 11:08:55 -0400 Received: by mail-wg0-f44.google.com with SMTP id y10so3386434wgg.15 for ; Thu, 02 Oct 2014 08:08:54 -0700 (PDT) Date: Thu, 2 Oct 2014 16:08:51 +0100 From: Stefan Hajnoczi Message-ID: <20141002150851.GF6250@stefanha-thinkpad.redhat.com> References: <1412182919-9550-1-git-send-email-stefanha@redhat.com> <1412182919-9550-8-git-send-email-stefanha@redhat.com> <542C583F.9010502@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="qp4W5+cUSnZs0RIF" Content-Disposition: inline In-Reply-To: <542C583F.9010502@redhat.com> Subject: Re: [Qemu-devel] [PATCH 07/11] block: let backup blockjob run in BDS AioContext List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Max Reitz Cc: Kevin Wolf , Paolo Bonzini , Fam Zheng , qemu-devel@nongnu.org, Stefan Hajnoczi --qp4W5+cUSnZs0RIF Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Oct 01, 2014 at 09:38:39PM +0200, Max Reitz wrote: > On 01.10.2014 19:01, Stefan Hajnoczi wrote: > >The backup block job must run in the BlockDriverState AioContext so that > >it works with dataplane. > > > >The basics of acquiring the AioContext are easy in blockdev.c. > > > >The completion code in block/backup.c must call bdrv_unref() from the > >main loop. Use block_job_defer_to_main_loop() to achieve that. > > > >Signed-off-by: Stefan Hajnoczi > >--- > > block/backup.c | 21 +++++++++++++++++++-- > > blockdev.c | 23 ++++++++++++++++------- > > 2 files changed, 35 insertions(+), 9 deletions(-) >=20 > Hm, so, if I run a backup blockjob from one thread (which is not the main > loop and not the BDS's AIO context) That cannot happen. The blockjob always runs with the BDS AioContext acquired - either because we explicitly did so in the main loop or because the dataplane IOThread acquires it. > and try to cancel it or set its speed > from another thread (e.g. the main loop), won't the blockjob hold the BDS= 's > AIO context lock as long as it runs and making it impossible to interfere? No, because of how the AioContext's RfifoLock lock works. It has a "contention callback" that kicks the aio_poll() loop. This allows the QEMU monitor to acquire the lock whenever an IOThread is blocked in poll(2). It uses an eventfd to force the IOThread out of poll(2) and this happens automatically in aio_context_acquire(). See aio_context_new() and aio_rfifolock_cb(). Stefan --qp4W5+cUSnZs0RIF Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEcBAEBAgAGBQJULWqDAAoJEJykq7OBq3PI6l8H/2my7p0jNAzJJ+z7eWpn5I2i e9SNIo26IWuzGjFJ0NcVzeSLjzdKVB/NgI11wG6TFGVOLBzIA13OA+tbHUzYpQeo hyNeV48wgQ5981QEEhGSdrUyOqSXCFhiZw3el7uJfYJR4r9FO81/VAWx8PaerrAW dvRQHqWy5+xr+fiCPQQHEla4P4Hy2ird0wGaMTYTd63bW4j1qCON+YaX1bwUYkxN Bp6kMCZBvnfAqJu9p/el7J95p8aSD5bZ0shvUSwCRLaL1heAlVqMKUjptrsosdCa N/fERRi3B7e0qr/aPUUWg8jYHBhrHPbdWdQUGDvjWTXiWelBiIB4EsaZW3USzFs= =536s -----END PGP SIGNATURE----- --qp4W5+cUSnZs0RIF--