From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:55411) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RERbB-0007Ha-KI for qemu-devel@nongnu.org; Thu, 13 Oct 2011 16:09:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RERb9-0002PS-PP for qemu-devel@nongnu.org; Thu, 13 Oct 2011 16:09:49 -0400 Received: from mtagate2.uk.ibm.com ([194.196.100.162]:40379) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RERb9-0002PF-ID for qemu-devel@nongnu.org; Thu, 13 Oct 2011 16:09:47 -0400 Received: from d06nrmr1507.portsmouth.uk.ibm.com (d06nrmr1507.portsmouth.uk.ibm.com [9.149.38.233]) by mtagate2.uk.ibm.com (8.13.1/8.13.1) with ESMTP id p9DK9kcn001353 for ; Thu, 13 Oct 2011 20:09:46 GMT Received: from d06av05.portsmouth.uk.ibm.com (d06av05.portsmouth.uk.ibm.com [9.149.37.229]) by d06nrmr1507.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p9DK9kId2625604 for ; Thu, 13 Oct 2011 21:09:46 +0100 Received: from d06av05.portsmouth.uk.ibm.com (loopback [127.0.0.1]) by d06av05.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p9DK9k1P025004 for ; Thu, 13 Oct 2011 14:09:46 -0600 From: Stefan Hajnoczi Date: Thu, 13 Oct 2011 21:09:31 +0100 Message-Id: <1318536572-23771-5-git-send-email-stefanha@linux.vnet.ibm.com> In-Reply-To: <1318536572-23771-1-git-send-email-stefanha@linux.vnet.ibm.com> References: <1318536572-23771-1-git-send-email-stefanha@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH 4/5] block: drop .bdrv_read()/.bdrv_write() emulation List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , Stefan Hajnoczi There is no need to emulate .bdrv_read()/.bdrv_write() since these interfaces are only called if aio and coroutine interfaces are not present. All valid BlockDrivers must implement either sync, aio, or coroutine interfaces. Signed-off-by: Stefan Hajnoczi --- block.c | 75 ++------------------------------------------------------------ 1 files changed, 3 insertions(+), 72 deletions(-) diff --git a/block.c b/block.c index 3d27bab..4d4d61a 100644 --- a/block.c +++ b/block.c @@ -57,10 +57,6 @@ static BlockDriverAIOCB *bdrv_aio_flush_em(BlockDriverState *bs, BlockDriverCompletionFunc *cb, void *opaque); static BlockDriverAIOCB *bdrv_aio_noop_em(BlockDriverState *bs, BlockDriverCompletionFunc *cb, void *opaque); -static int bdrv_read_em(BlockDriverState *bs, int64_t sector_num, - uint8_t *buf, int nb_sectors); -static int bdrv_write_em(BlockDriverState *bs, int64_t sector_num, - const uint8_t *buf, int nb_sectors); static int coroutine_fn bdrv_co_readv_em(BlockDriverState *bs, int64_t sector_num, int nb_sectors, QEMUIOVector *iov); @@ -197,14 +193,13 @@ void bdrv_register(BlockDriver *bdrv) bdrv->bdrv_co_readv = bdrv_co_readv_em; bdrv->bdrv_co_writev = bdrv_co_writev_em; + /* bdrv_co_readv_em()/brdv_co_writev_em() work in terms of aio, so if + * the block driver lacks aio we need to emulate that too. + */ if (!bdrv->bdrv_aio_readv) { /* add AIO emulation layer */ bdrv->bdrv_aio_readv = bdrv_aio_readv_em; bdrv->bdrv_aio_writev = bdrv_aio_writev_em; - } else if (!bdrv->bdrv_read) { - /* add synchronous IO emulation layer */ - bdrv->bdrv_read = bdrv_read_em; - bdrv->bdrv_write = bdrv_write_em; } } @@ -2834,70 +2829,6 @@ static BlockDriverAIOCB *bdrv_aio_noop_em(BlockDriverState *bs, return &acb->common; } -/**************************************************************/ -/* sync block device emulation */ - -static void bdrv_rw_em_cb(void *opaque, int ret) -{ - *(int *)opaque = ret; -} - -static int bdrv_read_em(BlockDriverState *bs, int64_t sector_num, - uint8_t *buf, int nb_sectors) -{ - int async_ret; - BlockDriverAIOCB *acb; - struct iovec iov; - QEMUIOVector qiov; - - async_ret = NOT_DONE; - iov.iov_base = (void *)buf; - iov.iov_len = nb_sectors * BDRV_SECTOR_SIZE; - qemu_iovec_init_external(&qiov, &iov, 1); - - acb = bs->drv->bdrv_aio_readv(bs, sector_num, &qiov, nb_sectors, - bdrv_rw_em_cb, &async_ret); - if (acb == NULL) { - async_ret = -1; - goto fail; - } - - while (async_ret == NOT_DONE) { - qemu_aio_wait(); - } - - -fail: - return async_ret; -} - -static int bdrv_write_em(BlockDriverState *bs, int64_t sector_num, - const uint8_t *buf, int nb_sectors) -{ - int async_ret; - BlockDriverAIOCB *acb; - struct iovec iov; - QEMUIOVector qiov; - - async_ret = NOT_DONE; - iov.iov_base = (void *)buf; - iov.iov_len = nb_sectors * BDRV_SECTOR_SIZE; - qemu_iovec_init_external(&qiov, &iov, 1); - - acb = bs->drv->bdrv_aio_writev(bs, sector_num, &qiov, nb_sectors, - bdrv_rw_em_cb, &async_ret); - if (acb == NULL) { - async_ret = -1; - goto fail; - } - while (async_ret == NOT_DONE) { - qemu_aio_wait(); - } - -fail: - return async_ret; -} - void bdrv_init(void) { module_call_init(MODULE_INIT_BLOCK); -- 1.7.6.3