[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PATCH v2 05/18] block/pcache: statistics collection read r
From: |
Pavel Butsykin |
Subject: |
[Qemu-block] [PATCH v2 05/18] block/pcache: statistics collection read requests |
Date: |
Fri, 30 Dec 2016 17:31:29 +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 | 32 +++++++++++++++++++++++++++++++-
1 file changed, 31 insertions(+), 1 deletion(-)
diff --git a/block/pcache.c b/block/pcache.c
index 7a67618408..296ae382b0 100644
--- a/block/pcache.c
+++ b/block/pcache.c
@@ -13,20 +13,38 @@
#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",
.head = QTAILQ_HEAD_INITIALIZER(runtime_opts.head),
.desc = {
+ {
+ .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;
+
static coroutine_fn int pcache_co_preadv(BlockDriverState *bs, uint64_t offset,
uint64_t bytes, QEMUIOVector *qiov,
int flags)
{
+ BDRVPCacheState *s = bs->opaque;
+
+ rbcache_search_and_insert(s->req_stats, offset, bytes);
+
return bdrv_co_preadv(bs->file, offset, bytes, qiov, flags);
}
@@ -37,6 +55,13 @@ static coroutine_fn int pcache_co_pwritev(BlockDriverState
*bs, uint64_t offset,
return bdrv_co_pwritev(bs->file, offset, bytes, qiov, flags);
}
+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)
{
@@ -58,7 +83,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;
@@ -66,6 +93,9 @@ fail:
static void pcache_close(BlockDriverState *bs)
{
+ BDRVPCacheState *s = bs->opaque;
+
+ rbcache_destroy(s->req_stats);
}
static int64_t pcache_getlength(BlockDriverState *bs)
@@ -81,7 +111,7 @@ static bool
pcache_recurse_is_first_non_filter(BlockDriverState *bs,
static BlockDriver bdrv_pcache = {
.format_name = "pcache",
- .instance_size = 0,
+ .instance_size = sizeof(BDRVPCacheState),
.bdrv_file_open = pcache_file_open,
.bdrv_close = pcache_close,
--
2.11.0
- [Qemu-block] [PATCH v2 16/18] block/pcache: drop used pcache nodes, (continued)
- [Qemu-block] [PATCH v2 16/18] block/pcache: drop used pcache nodes, Pavel Butsykin, 2016/12/30
- [Qemu-block] [PATCH v2 12/18] block/pcache: inflight readahead request waiting for read, Pavel Butsykin, 2016/12/30
- [Qemu-block] [PATCH v2 02/18] util/rbtree: add rbtree from linux kernel, Pavel Butsykin, 2016/12/30
- [Qemu-block] [PATCH v2 18/18] block/pcache: add tracepoints, Pavel Butsykin, 2016/12/30
- [Qemu-block] [PATCH v2 15/18] block/pcache: pick up parts of the cache, Pavel Butsykin, 2016/12/30
- [Qemu-block] [PATCH v2 03/18] util/rbcache: range-based cache core, Pavel Butsykin, 2016/12/30
- [Qemu-block] [PATCH v2 08/18] block/pcache: add AIO readahead, Pavel Butsykin, 2016/12/30
- [Qemu-block] [PATCH v2 07/18] block/pcache: updating statistics for overlapping requests, Pavel Butsykin, 2016/12/30
- [Qemu-block] [PATCH v2 14/18] block/pcache: up-to-date cache for removed nodes, Pavel Butsykin, 2016/12/30
- [Qemu-block] [PATCH v2 17/18] qapi: allow blockdev-add for pcache, Pavel Butsykin, 2016/12/30
- [Qemu-block] [PATCH v2 05/18] block/pcache: statistics collection read requests,
Pavel Butsykin <=
- [Qemu-block] [PATCH v2 10/18] block/pcache: cache invalidation on write requests, Pavel Butsykin, 2016/12/30
- [Qemu-block] [PATCH v2 06/18] block/pcache: skip large aio read, Pavel Butsykin, 2016/12/30
- [Qemu-block] [PATCH v2 04/18] tests/test-rbcache: add test cases, Pavel Butsykin, 2016/12/30
- [Qemu-block] [PATCH v2 01/18] block/pcache: empty pcache driver filter, Pavel Butsykin, 2016/12/30
- [Qemu-block] [PATCH v2 09/18] block/pcache: skip readahead for unallocated clusters, Pavel Butsykin, 2016/12/30
- [Qemu-block] [PATCH v2 13/18] block/pcache: write through, Pavel Butsykin, 2016/12/30