[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PATCH RFC 02/22] block/pcache: add own AIOCB block
From: |
Pavel Butsykin |
Subject: |
[Qemu-block] [PATCH RFC 02/22] block/pcache: add own AIOCB block |
Date: |
Thu, 25 Aug 2016 16:44:01 +0300 |
Signed-off-by: Pavel Butsykin <address@hidden>
---
block/pcache.c | 43 +++++++++++++++++++++++++++++++++++--------
1 file changed, 35 insertions(+), 8 deletions(-)
diff --git a/block/pcache.c b/block/pcache.c
index 770bbc0..74a4bc4 100644
--- a/block/pcache.c
+++ b/block/pcache.c
@@ -24,12 +24,22 @@
#include "qemu/osdep.h"
#include "block/block_int.h"
+#include "block/raw-aio.h"
#include "qapi/error.h"
#include "qapi/qmp/qstring.h"
+typedef struct PrefCacheAIOCB {
+ BlockAIOCB common;
+
+ QEMUIOVector *qiov;
+ uint64_t sector_num;
+ uint32_t nb_sectors;
+ int aio_type;
+ int ret;
+} PrefCacheAIOCB;
static const AIOCBInfo pcache_aiocb_info = {
- .aiocb_size = sizeof(BlockAIOCB),
+ .aiocb_size = sizeof(PrefCacheAIOCB),
};
static QemuOptsList runtime_opts = {
@@ -47,14 +57,29 @@ static QemuOptsList runtime_opts = {
static void pcache_aio_cb(void *opaque, int ret)
{
+ PrefCacheAIOCB *acb = opaque;
- BlockAIOCB *acb = opaque;
-
- acb->cb(acb->opaque, ret);
+ acb->common.cb(acb->common.opaque, ret);
qemu_aio_unref(acb);
}
+static PrefCacheAIOCB *pcache_aio_get(BlockDriverState *bs, int64_t sector_num,
+ QEMUIOVector *qiov, int nb_sectors,
+ BlockCompletionFunc *cb, void *opaque,
+ int type)
+{
+ PrefCacheAIOCB *acb = qemu_aio_get(&pcache_aiocb_info, bs, cb, opaque);
+
+ acb->sector_num = sector_num;
+ acb->nb_sectors = nb_sectors;
+ acb->qiov = qiov;
+ acb->aio_type = type;
+ acb->ret = 0;
+
+ return acb;
+}
+
static BlockAIOCB *pcache_aio_readv(BlockDriverState *bs,
int64_t sector_num,
QEMUIOVector *qiov,
@@ -62,11 +87,12 @@ static BlockAIOCB *pcache_aio_readv(BlockDriverState *bs,
BlockCompletionFunc *cb,
void *opaque)
{
- BlockAIOCB *acb = qemu_aio_get(&pcache_aiocb_info, bs, cb, opaque);
+ PrefCacheAIOCB *acb = pcache_aio_get(bs, sector_num, qiov, nb_sectors, cb,
+ opaque, QEMU_AIO_READ);
bdrv_aio_readv(bs->file, sector_num, qiov, nb_sectors,
pcache_aio_cb, acb);
- return acb;
+ return &acb->common;
}
static BlockAIOCB *pcache_aio_writev(BlockDriverState *bs,
@@ -76,11 +102,12 @@ static BlockAIOCB *pcache_aio_writev(BlockDriverState *bs,
BlockCompletionFunc *cb,
void *opaque)
{
- BlockAIOCB *acb = qemu_aio_get(&pcache_aiocb_info, bs, cb, opaque);
+ PrefCacheAIOCB *acb = pcache_aio_get(bs, sector_num, qiov, nb_sectors, cb,
+ opaque, QEMU_AIO_WRITE);
bdrv_aio_writev(bs->file, sector_num, qiov, nb_sectors,
pcache_aio_cb, acb);
- return acb;
+ return &acb->common;
}
static int pcache_file_open(BlockDriverState *bs, QDict *options, int flags,
--
2.8.3
- [Qemu-block] [PATCH RFC 00/22] I/O prefetch cache, Pavel Butsykin, 2016/08/25
- [Qemu-block] [PATCH RFC 01/22] block/pcache: empty pcache driver filter, Pavel Butsykin, 2016/08/25
- [Qemu-block] [PATCH RFC 04/22] block/pcache: add pcache debug build, Pavel Butsykin, 2016/08/25
- [Qemu-block] [PATCH RFC 02/22] block/pcache: add own AIOCB block,
Pavel Butsykin <=
- [Qemu-block] [PATCH RFC 07/22] block/pcache: introduce LRU as method of memory, Pavel Butsykin, 2016/08/25
- [Qemu-block] [PATCH RFC 10/22] block/pcache: add check node leak, Pavel Butsykin, 2016/08/25
- [Qemu-block] [PATCH RFC 08/22] block/pcache: implement pickup parts of the cache, Pavel Butsykin, 2016/08/25
- [Qemu-block] [PATCH RFC 11/22] add QEMU style defines for __sync_add_and_fetch, Pavel Butsykin, 2016/08/25
- [Qemu-block] [PATCH RFC 12/22] block/pcache: implement read cache to qiov and drop node during aio write, Pavel Butsykin, 2016/08/25
- [Qemu-block] [PATCH RFC 15/22] block/pcache: simple readahead one chunk forward, Pavel Butsykin, 2016/08/25
- [Qemu-block] [PATCH RFC 22/22] block/pcache: drop used pcache node, Pavel Butsykin, 2016/08/25
- [Qemu-block] [PATCH RFC 17/22] block/pcache: skip readahead for non-sequential requests, Pavel Butsykin, 2016/08/25
- [Qemu-block] [PATCH RFC 16/22] block/pcache: pcache readahead node around, Pavel Butsykin, 2016/08/25
- [Qemu-block] [PATCH RFC 20/22] block/pcache: implement pcache error handling of aio cb, Pavel Butsykin, 2016/08/25