[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PATCH v1 08/18] block/pcache: updating statistics for over
From: |
Pavel Butsykin |
Subject: |
[Qemu-block] [PATCH v1 08/18] block/pcache: updating statistics for overlapping requests |
Date: |
Tue, 15 Nov 2016 09:37:05 +0300 |
When updating the statistics sometimes i/O requests can overlap each other,
in this case the requests are not stored in the statistics. It's not very good,
especially when the requests have a small range of intersection.
We can cut the requests in the intersection and add the pieces of requests in
the statistics. Maybe not significantly, but it can make the statistics more
accurate. Here, update_req_stats() adds the ability to save overlapping
requests.
Signed-off-by: Pavel Butsykin <address@hidden>
---
block/pcache.c | 36 +++++++++++++++++++++++++++++++++++-
1 file changed, 35 insertions(+), 1 deletion(-)
diff --git a/block/pcache.c b/block/pcache.c
index bfc7e97..dd598f3 100644
--- a/block/pcache.c
+++ b/block/pcache.c
@@ -64,6 +64,40 @@ static void pcache_aio_cb(void *opaque, int ret)
qemu_coroutine_enter(acb->co);
}
+static void update_req_stats(RBCache *rbcache, uint64_t offset, uint64_t bytes)
+{
+ do {
+ RBCacheNode *node = rbcache_search_and_insert(rbcache, offset, bytes);
+ /* The node was successfully added or already exists */
+ if (node->offset <= offset &&
+ node->offset + node->bytes >= offset + bytes)
+ {
+ break;
+ }
+
+ /* Request covers the whole node */
+ if (offset <= node->offset &&
+ offset + bytes >= node->offset + node->bytes)
+ {
+ rbcache_remove(rbcache, node);
+ continue;
+ }
+
+ if (offset < node->offset) {
+ RBCacheNode *new_node =
+ rbcache_node_alloc(rbcache, offset, node->offset - offset);
+ if (new_node != rbcache_insert(rbcache, new_node)) {
+ /* The presence of the node in this range is impossible */
+ abort();
+ }
+ break;
+ }
+
+ bytes = (offset + bytes) - (node->offset + node->bytes);
+ offset = node->offset + node->bytes;
+ } while (true);
+}
+
static coroutine_fn int pcache_co_preadv(BlockDriverState *bs, uint64_t offset,
uint64_t bytes, QEMUIOVector *qiov,
int flags)
@@ -74,7 +108,7 @@ static coroutine_fn int pcache_co_preadv(BlockDriverState
*bs, uint64_t offset,
};
if (s->max_aio_size >= bytes) {
- rbcache_search_and_insert(s->req_stats, offset, bytes);
+ update_req_stats(s->req_stats, offset, bytes);
}
bdrv_aio_preadv(bs->file, offset, qiov, bytes, pcache_aio_cb, &acb);
--
2.10.1
- [Qemu-block] [PATCH v1 00/18] I/O prefetch cache, Pavel Butsykin, 2016/11/15
- [Qemu-block] [PATCH v1 07/18] block/pcache: skip large aio read, Pavel Butsykin, 2016/11/15
- [Qemu-block] [PATCH v1 04/18] util/rbcache: range-based cache core, Pavel Butsykin, 2016/11/15
- [Qemu-block] [PATCH v1 13/18] block/pcache: inflight readahead request waiting for aio read, Pavel Butsykin, 2016/11/15
- [Qemu-block] [PATCH v1 10/18] block/pcache: skip readahead for unallocated clusters, Pavel Butsykin, 2016/11/15
- [Qemu-block] [PATCH v1 05/18] tests/test-rbcache: add test cases, Pavel Butsykin, 2016/11/15
- [Qemu-block] [PATCH v1 14/18] backup/pcache: pick up parts of the cache, Pavel Butsykin, 2016/11/15
- [Qemu-block] [PATCH v1 08/18] block/pcache: updating statistics for overlapping requests,
Pavel Butsykin <=
- [Qemu-block] [PATCH v1 12/18] block/pcache: add reading data from the cache, Pavel Butsykin, 2016/11/15
- [Qemu-block] [PATCH v1 03/18] util/rbtree: add rbtree from linux kernel, Pavel Butsykin, 2016/11/15
- [Qemu-block] [PATCH v1 06/18] block/pcache: statistics collection read requests, Pavel Butsykin, 2016/11/15
- [Qemu-block] [PATCH v1 02/18] block/pcache: empty pcache driver filter, Pavel Butsykin, 2016/11/15
- [Qemu-block] [PATCH v1 11/18] block/pcache: cache invalidation on AIO write requests, Pavel Butsykin, 2016/11/15
- [Qemu-block] [PATCH v1 15/18] block/pcache: drop used pcache nodes, Pavel Butsykin, 2016/11/15
- [Qemu-block] [PATCH v1 17/18] block/pcache: add tracepoints, Pavel Butsykin, 2016/11/15