From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39548) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XEVW1-0002VH-9H for qemu-devel@nongnu.org; Mon, 04 Aug 2014 23:34:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XEVVu-0001Ui-VX for qemu-devel@nongnu.org; Mon, 04 Aug 2014 23:34:21 -0400 Received: from mail-pd0-f175.google.com ([209.85.192.175]:42427) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XEVVu-0001Uc-Pr for qemu-devel@nongnu.org; Mon, 04 Aug 2014 23:34:14 -0400 Received: by mail-pd0-f175.google.com with SMTP id r10so506682pdi.20 for ; Mon, 04 Aug 2014 20:34:13 -0700 (PDT) From: Ming Lei Date: Tue, 5 Aug 2014 11:33:05 +0800 Message-Id: <1407209598-2572-5-git-send-email-ming.lei@canonical.com> In-Reply-To: <1407209598-2572-1-git-send-email-ming.lei@canonical.com> References: <1407209598-2572-1-git-send-email-ming.lei@canonical.com> Subject: [Qemu-devel] [PATCH v1 04/17] block: prepare for supporting selective bypass coroutine List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org, Peter Maydell , Paolo Bonzini , Stefan Hajnoczi Cc: Kevin Wolf , Ming Lei , Fam Zheng , "Michael S. Tsirkin" If device thinks that it isn't necessary to apply coroutine in its performance sensitive path, it can call block_set_bypass_co(false) to bypass the coroutine and just call the function directly in the aio read/write path. One example is virtio-blk dataplane. Signed-off-by: Ming Lei --- block.c | 10 ++++++++++ include/block/block.h | 3 +++ include/block/block_int.h | 3 +++ 3 files changed, 16 insertions(+) diff --git a/block.c b/block.c index 8cf519b..ac184ef 100644 --- a/block.c +++ b/block.c @@ -5840,3 +5840,13 @@ void bdrv_flush_io_queue(BlockDriverState *bs) bdrv_flush_io_queue(bs->file); } } + +void bdrv_set_bypass_co(BlockDriverState *bs, bool bypass) +{ + bs->bypass_co = bypass; +} + +bool bdrv_get_bypass_co(BlockDriverState *bs) +{ + return bs->bypass_co; +} diff --git a/include/block/block.h b/include/block/block.h index f08471d..92f2f3a 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -588,4 +588,7 @@ void bdrv_io_plug(BlockDriverState *bs); void bdrv_io_unplug(BlockDriverState *bs); void bdrv_flush_io_queue(BlockDriverState *bs); +void bdrv_set_bypass_co(BlockDriverState *bs, bool bypass); +bool bdrv_get_bypass_co(BlockDriverState *bs); + #endif diff --git a/include/block/block_int.h b/include/block/block_int.h index 7b541a0..9fa2f4c 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -354,6 +354,9 @@ struct BlockDriverState { /* Whether produces zeros when read beyond eof */ bool zero_beyond_eof; + /* Whether bypasses coroutine when doing aio read & write */ + bool bypass_co; + /* Alignment requirement for offset/length of I/O requests */ unsigned int request_alignment; -- 1.7.9.5