[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 5 of 5] bdrv_aio_readv/writev
From: |
Andrea Arcangeli |
Subject: |
[Qemu-devel] [PATCH 5 of 5] bdrv_aio_readv/writev |
Date: |
Fri, 12 Dec 2008 19:16:47 +0100 |
From: Andrea Arcangeli <address@hidden>
bdrv_aio_readv/writev methods (depends on lower level bdrv_aio_readv).
Signed-off-by: Andrea Arcangeli <address@hidden>
---
diff --git a/block.c b/block.c
--- a/block.c
+++ b/block.c
@@ -1296,6 +1296,50 @@ void bdrv_aio_cancel(BlockDriverAIOCB *a
drv->bdrv_aio_cancel(acb);
}
+BlockDriverAIOCB *bdrv_aio_readv(BlockDriverState *bs, int64_t sector_num,
+ struct iovec *iov, int iovcnt, size_t len,
+ BlockDriverCompletionFunc *cb, void *opaque)
+{
+ BlockDriver *drv = bs->drv;
+ BlockDriverAIOCB *ret;
+
+
+ if (!drv)
+ return NULL;
+
+ ret = drv->bdrv_aio_readv(bs, sector_num, iov, iovcnt, len, cb, opaque);
+
+ if (ret) {
+ /* Update stats even though technically transfer has not happened. */
+ bs->rd_bytes += (unsigned) len;
+ bs->rd_ops ++;
+ }
+
+ return ret;
+}
+
+BlockDriverAIOCB *bdrv_aio_writev(BlockDriverState *bs, int64_t sector_num,
+ struct iovec *iov, int iovcnt, size_t len,
+ BlockDriverCompletionFunc *cb, void *opaque)
+{
+ BlockDriver *drv = bs->drv;
+ BlockDriverAIOCB *ret;
+
+
+ if (!drv)
+ return NULL;
+
+ ret = drv->bdrv_aio_writev(bs, sector_num, iov, iovcnt, len, cb, opaque);
+
+ if (ret) {
+ /* Update stats even though technically transfer has not happened. */
+ bs->rd_bytes += (unsigned) len;
+ bs->rd_ops ++;
+ }
+
+ return ret;
+}
+
/**************************************************************/
/* async block device emulation */
diff --git a/block.h b/block.h
--- a/block.h
+++ b/block.h
@@ -85,6 +85,13 @@ int bdrv_commit(BlockDriverState *bs);
/* async block I/O */
typedef struct BlockDriverAIOCB BlockDriverAIOCB;
typedef void BlockDriverCompletionFunc(void *opaque, int ret);
+typedef BlockDriverAIOCB *BlockDriverAIOIOV(BlockDriverState *bs,
+ int64_t sector_num,
+ struct iovec *iov,
+ int iovnct,
+ size_t len,
+ BlockDriverCompletionFunc *cb,
+ void *opaque);
BlockDriverAIOCB *bdrv_aio_read(BlockDriverState *bs, int64_t sector_num,
uint8_t *buf, int nb_sectors,
@@ -93,6 +100,12 @@ BlockDriverAIOCB *bdrv_aio_write(BlockDr
const uint8_t *buf, int nb_sectors,
BlockDriverCompletionFunc *cb, void *opaque);
void bdrv_aio_cancel(BlockDriverAIOCB *acb);
+BlockDriverAIOCB *bdrv_aio_readv(BlockDriverState *bs, int64_t sector_num,
+ struct iovec *iov, int iovnct, size_t len,
+ BlockDriverCompletionFunc *cb, void *opaque);
+BlockDriverAIOCB *bdrv_aio_writev(BlockDriverState *bs, int64_t sector_num,
+ struct iovec *iov, int iovnct, size_t len,
+ BlockDriverCompletionFunc *cb, void *opaque);
int qemu_key_check(BlockDriverState *bs, const char *name);
diff --git a/block_int.h b/block_int.h
--- a/block_int.h
+++ b/block_int.h
@@ -55,6 +55,8 @@ struct BlockDriver {
int64_t sector_num, const uint8_t *buf, int nb_sectors,
BlockDriverCompletionFunc *cb, void *opaque);
void (*bdrv_aio_cancel)(BlockDriverAIOCB *acb);
+ BlockDriverAIOIOV *bdrv_aio_readv;
+ BlockDriverAIOIOV *bdrv_aio_writev;
int aiocb_size;
const char *protocol_name;