From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34468) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XZNI6-0002X0-1R for qemu-devel@nongnu.org; Wed, 01 Oct 2014 13:02:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XZNHz-0001Z6-T6 for qemu-devel@nongnu.org; Wed, 01 Oct 2014 13:02:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44250) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XZNHz-0001Yo-MZ for qemu-devel@nongnu.org; Wed, 01 Oct 2014 13:02:07 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s91H26xF000869 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Wed, 1 Oct 2014 13:02:06 -0400 From: Stefan Hajnoczi Date: Wed, 1 Oct 2014 18:01:48 +0100 Message-Id: <1412182919-9550-1-git-send-email-stefanha@redhat.com> Subject: [Qemu-devel] [PATCH 00/11] block: allow blockjobs to coexist with dataplane List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , Paolo Bonzini , Fam Zheng , Stefan Hajnoczi , Max Reitz Almost all the infrastructure is in place to make blockjobs safe for use with dataplane: * Op blockers all us to exclude commands that could conflict with a blockjob or dataplane. * AioContext acquire/release allows threads to temporarily access a BlockDriverState that is running in another thread. This series introduces a few additional helpers: * 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. * 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() function). The approach taken in this series is to convert the blockdev.c monitor command so it acquires the BlockDriverState's AioContext. Normally only 1 AioContext is involved at a time but the mirror job's to_replace argument can involve a second AioContext. Then the block job code itself is converted to defer main loop code using block_job_defer_to_main_loop(). Example: $ qemu-system-x86_64 -enable-kvm -m 1024 \ -drive if=none,id=drive0,file=test.img \ -object iothread,iothread0 \ -device virtio-blk-pci,drive=drive0,iothread=iothread0 (qemu) drive_mirror drive0 test2.img 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! block.c | 49 +++++++++-- block/backup.c | 21 ++++- block/commit.c | 72 ++++++++++------ block/mirror.c | 85 +++++++++++++------ block/stream.c | 50 +++++++---- blockdev.c | 179 +++++++++++++++++++++++++++++----------- blockjob.c | 36 ++++++++ hw/block/dataplane/virtio-blk.c | 5 ++ include/block/block.h | 1 + include/block/blockjob.h | 19 +++++ 10 files changed, 394 insertions(+), 123 deletions(-) -- 1.9.3