From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42057) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XjS6I-00025F-1H for qemu-devel@nongnu.org; Wed, 29 Oct 2014 08:11:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XjS6C-00039M-DS for qemu-devel@nongnu.org; Wed, 29 Oct 2014 08:11:41 -0400 Received: from mail-lb0-x22a.google.com ([2a00:1450:4010:c04::22a]:58589) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XjS6C-00039G-1V for qemu-devel@nongnu.org; Wed, 29 Oct 2014 08:11:36 -0400 Received: by mail-lb0-f170.google.com with SMTP id 10so2352098lbg.15 for ; Wed, 29 Oct 2014 05:11:35 -0700 (PDT) Date: Wed, 29 Oct 2014 12:11:31 +0000 From: Stefan Hajnoczi Message-ID: <20141029121131.GB32180@stefanha-thinkpad.redhat.com> References: <1413889440-32577-1-git-send-email-stefanha@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="zx4FCpZtqtKETZ7O" Content-Disposition: inline In-Reply-To: <1413889440-32577-1-git-send-email-stefanha@redhat.com> Subject: Re: [Qemu-devel] [PATCH v2 00/11] block: allow blockjobs to coexist with dataplane List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: Kevin Wolf , Paolo Bonzini , Fam Zheng , qemu-devel@nongnu.org, Max Reitz --zx4FCpZtqtKETZ7O Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Oct 21, 2014 at 12:03:49PM +0100, Stefan Hajnoczi wrote: > v2: > * Protect block_job_defer_to_main_loop_bh() against AioContext change [M= ax] > * Drop unnecessary if (buf) around qemu_vfree(buf) [Max] >=20 > Almost all the infrastructure is in place to make blockjobs safe for use = with > dataplane: >=20 > * Op blockers all us to exclude commands that could conflict with a blo= ckjob > or dataplane. >=20 > * AioContext acquire/release allows threads to temporarily access a > BlockDriverState that is running in another thread. >=20 > This series introduces a few additional helpers: >=20 > * block_job_defer_to_main_loop() which allows blockjobs to run their > completion code in the QEMU main loop. This is necessary because some > operations are not safe outside the QEMU global mutex. >=20 > * bdrv_drain() which can be used in limited cases to wait for in-flight > requests to complete (as opposed to the global bdrv_drain_all() funct= ion). >=20 > The approach taken in this series is to convert the blockdev.c monitor co= mmand > so it acquires the BlockDriverState's AioContext. Normally only 1 AioCon= text > is involved at a time but the mirror job's to_replace argument can involv= e a > second AioContext. >=20 > Then the block job code itself is converted to defer main loop code using > block_job_defer_to_main_loop(). >=20 > Example: >=20 > $ qemu-system-x86_64 -enable-kvm -m 1024 \ > -drive if=3Dnone,id=3Ddrive0,file=3Dtest.img \ > -object iothread,iothread0 \ > -device virtio-blk-pci,drive=3Ddrive0,iothread=3Diothread0 > (qemu) drive_mirror drive0 test2.img >=20 > Stefan Hajnoczi (11): > block: acquire AioContext in generic blockjob QMP commands > blockdev: acquire AioContext in do_qmp_query_block_jobs_one() > blockdev: acquire AioContext in blockdev_mark_auto_del() > blockdev: add note that block_job_cb() must be thread-safe > blockjob: add block_job_defer_to_main_loop() > block: add bdrv_drain() > block: let backup blockjob run in BDS AioContext > block: let stream blockjob run in BDS AioContext > block: let mirror blockjob run in BDS AioContext > block: let commit blockjob run in BDS AioContext > block: declare blockjobs and dataplane friends! >=20 > block.c | 49 +++++++++-- > block/backup.c | 21 ++++- > block/commit.c | 70 ++++++++++------ > block/mirror.c | 85 +++++++++++++------ > block/stream.c | 50 +++++++---- > blockdev.c | 179 +++++++++++++++++++++++++++++-----= ------ > blockjob.c | 46 +++++++++++ > hw/block/dataplane/virtio-blk.c | 5 ++ > include/block/block.h | 1 + > include/block/blockjob.h | 19 +++++ > 10 files changed, 402 insertions(+), 123 deletions(-) Applied to my block tree: https://github.com/stefanha/qemu/commits/block Stefan --zx4FCpZtqtKETZ7O Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEcBAEBAgAGBQJUUNlzAAoJEJykq7OBq3PI7PkIAJi+x00JM4uroU2VvJ6lip21 dYPIw9G+ycrHnqRPshnoa5f//GrKfY8yjsHQsy6p9UXhW21Pesg1ZC5CqjBpsB8W NoG8MRADZLuHCNf2yaYw3ZZkJ5PuBbO5obUEJ7Umz67K5kjEQXguDD9zlVM0aEhU yCqOo9oJbzV1Phy0RBZElV9yYgznbjszf3pZPMELp/I2Ei1JraJ98dEDp8Qykrym ODuS0DPHeUxJ8T9I/7eKAIlxYcKR51S5w+hfNxaFC4LCfX52e+pSkYsRD28Yfwbe 3pJOfvgQqVzpt9tTj4pk4/qDxhCd+te561BI+/+XLGcR7kp/tkUQ42fOZIzeQOU= =GCsO -----END PGP SIGNATURE----- --zx4FCpZtqtKETZ7O--