[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 23/24] block: drop .bdrv_read()/.bdrv_write() emulat
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PATCH 23/24] block: drop .bdrv_read()/.bdrv_write() emulation |
Date: |
Fri, 14 Oct 2011 18:49:18 +0200 |
From: Stefan Hajnoczi <address@hidden>
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 <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
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.4
- [Qemu-devel] [PATCH 10/24] block/vvfat: Remove unused code, (continued)
- [Qemu-devel] [PATCH 10/24] block/vvfat: Remove unused code, Kevin Wolf, 2011/10/14
- [Qemu-devel] [PATCH 12/24] block: directly invoke .bdrv_aio_*() in bdrv_co_io_em(), Kevin Wolf, 2011/10/14
- [Qemu-devel] [PATCH 14/24] block: split out bdrv_co_do_readv() and bdrv_co_do_writev(), Kevin Wolf, 2011/10/14
- [Qemu-devel] [PATCH 15/24] block: switch bdrv_read()/bdrv_write() to coroutines, Kevin Wolf, 2011/10/14
- [Qemu-devel] [PATCH 17/24] block: mark blocks dirty on coroutine write completion, Kevin Wolf, 2011/10/14
- [Qemu-devel] [PATCH 16/24] block: switch bdrv_aio_readv() to coroutines, Kevin Wolf, 2011/10/14
- [Qemu-devel] [PATCH 18/24] block: switch bdrv_aio_writev() to coroutines, Kevin Wolf, 2011/10/14
- [Qemu-devel] [PATCH 19/24] linux-aio: Allow reads beyond the end of growable images, Kevin Wolf, 2011/10/14
- [Qemu-devel] [PATCH 20/24] block: drop emulation functions that use coroutines, Kevin Wolf, 2011/10/14
- [Qemu-devel] [PATCH 23/24] block: drop .bdrv_read()/.bdrv_write() emulation,
Kevin Wolf <=
- [Qemu-devel] [PATCH 22/24] block: use coroutine interface for raw format, Kevin Wolf, 2011/10/14
- [Qemu-devel] [PATCH 24/24] block: drop bdrv_has_async_rw(), Kevin Wolf, 2011/10/14
- [Qemu-devel] [PATCH 21/24] raw-posix: remove bdrv_read()/bdrv_write(), Kevin Wolf, 2011/10/14
- Re: [Qemu-devel] [PULL 00/24] Block patches, Anthony Liguori, 2011/10/14