[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v1 06/18] block/pcache: statistics collection read r
From: |
Pavel Butsykin |
Subject: |
[Qemu-devel] [PATCH v1 06/18] block/pcache: statistics collection read requests |
Date: |
Tue, 15 Nov 2016 09:37:03 +0300 |
Here the rbcache is used as a repository statistics requests, in fact, data
requests are not cached, so we have the ability to store a large number of
requests. We need statistics requests to determine the sequential requests.
Signed-off-by: Pavel Butsykin <address@hidden>
---
block/pcache.c | 31 ++++++++++++++++++++++++++++++-
1 file changed, 30 insertions(+), 1 deletion(-)
diff --git a/block/pcache.c b/block/pcache.c
index 59461df..60b1f93 100644
--- a/block/pcache.c
+++ b/block/pcache.c
@@ -13,7 +13,9 @@
#include "block/block_int.h"
#include "qapi/error.h"
#include "qapi/qmp/qstring.h"
+#include "qemu/rbcache.h"
+#define PCACHE_OPT_STATS_SIZE "pcache-stats-size"
static QemuOptsList runtime_opts = {
.name = "pcache",
@@ -24,10 +26,22 @@ static QemuOptsList runtime_opts = {
.type = QEMU_OPT_STRING,
.help = "[internal use only, will be removed]",
},
+ {
+ .name = PCACHE_OPT_STATS_SIZE,
+ .type = QEMU_OPT_SIZE,
+ .help = "Total volume of requests for statistics",
+ },
{ /* end of list */ }
},
};
+#define MB_BITS 20
+#define PCACHE_DEFAULT_STATS_SIZE (3 << MB_BITS)
+
+typedef struct BDRVPCacheState {
+ RBCache *req_stats;
+} BDRVPCacheState;
+
typedef struct PCacheAIOCB {
Coroutine *co;
int ret;
@@ -45,10 +59,13 @@ static coroutine_fn int pcache_co_preadv(BlockDriverState
*bs, uint64_t offset,
uint64_t bytes, QEMUIOVector *qiov,
int flags)
{
+ BDRVPCacheState *s = bs->opaque;
PCacheAIOCB acb = {
.co = qemu_coroutine_self(),
};
+ rbcache_search_and_insert(s->req_stats, offset, bytes);
+
bdrv_aio_preadv(bs->file, offset, qiov, bytes, pcache_aio_cb, &acb);
qemu_coroutine_yield();
@@ -71,6 +88,13 @@ static coroutine_fn int pcache_co_pwritev(BlockDriverState
*bs, uint64_t offset,
return acb.ret;
}
+static void pcache_state_init(QemuOpts *opts, BDRVPCacheState *s)
+{
+ uint64_t stats_size = qemu_opt_get_size(opts, PCACHE_OPT_STATS_SIZE,
+ PCACHE_DEFAULT_STATS_SIZE);
+ s->req_stats = rbcache_create(NULL, NULL, stats_size, RBCACHE_FIFO, s);
+}
+
static int pcache_file_open(BlockDriverState *bs, QDict *options, int flags,
Error **errp)
{
@@ -92,7 +116,9 @@ static int pcache_file_open(BlockDriverState *bs, QDict
*options, int flags,
if (local_err) {
ret = -EINVAL;
error_propagate(errp, local_err);
+ goto fail;
}
+ pcache_state_init(opts, bs->opaque);
fail:
qemu_opts_del(opts);
return ret;
@@ -100,6 +126,9 @@ fail:
static void pcache_close(BlockDriverState *bs)
{
+ BDRVPCacheState *s = bs->opaque;
+
+ rbcache_destroy(s->req_stats);
}
static void pcache_parse_filename(const char *filename, QDict *options,
@@ -122,7 +151,7 @@ static bool
pcache_recurse_is_first_non_filter(BlockDriverState *bs,
static BlockDriver bdrv_pcache = {
.format_name = "pcache",
.protocol_name = "pcache",
- .instance_size = 0,
+ .instance_size = sizeof(BDRVPCacheState),
.bdrv_parse_filename = pcache_parse_filename,
.bdrv_file_open = pcache_file_open,
--
2.10.1
- [Qemu-devel] [PATCH v1 05/18] tests/test-rbcache: add test cases, (continued)
- [Qemu-devel] [PATCH v1 05/18] tests/test-rbcache: add test cases, Pavel Butsykin, 2016/11/15
- [Qemu-devel] [PATCH v1 14/18] backup/pcache: pick up parts of the cache, Pavel Butsykin, 2016/11/15
- [Qemu-devel] [PATCH v1 08/18] block/pcache: updating statistics for overlapping requests, Pavel Butsykin, 2016/11/15
- [Qemu-devel] [PATCH v1 12/18] block/pcache: add reading data from the cache, Pavel Butsykin, 2016/11/15
- [Qemu-devel] [PATCH v1 03/18] util/rbtree: add rbtree from linux kernel, Pavel Butsykin, 2016/11/15
- [Qemu-devel] [PATCH v1 02/18] block/pcache: empty pcache driver filter, Pavel Butsykin, 2016/11/15
- [Qemu-devel] [PATCH v1 06/18] block/pcache: statistics collection read requests,
Pavel Butsykin <=
- [Qemu-devel] [PATCH v1 11/18] block/pcache: cache invalidation on AIO write requests, Pavel Butsykin, 2016/11/15
- [Qemu-devel] [PATCH v1 15/18] block/pcache: drop used pcache nodes, Pavel Butsykin, 2016/11/15
- [Qemu-devel] [PATCH v1 17/18] block/pcache: add tracepoints, Pavel Butsykin, 2016/11/15
- [Qemu-devel] [PATCH v1 18/18] block/pcache: debug build, Pavel Butsykin, 2016/11/15
- [Qemu-devel] [PATCH v1 01/18] block/io: add bdrv_aio_{preadv, pwritev}, Pavel Butsykin, 2016/11/15
[Qemu-devel] [PATCH v1 09/18] block/pcache: add AIO readahead, Pavel Butsykin, 2016/11/15