[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v1 15/18] block/pcache: drop used pcache nodes
From: |
Pavel Butsykin |
Subject: |
[Qemu-devel] [PATCH v1 15/18] block/pcache: drop used pcache nodes |
Date: |
Tue, 15 Nov 2016 09:37:12 +0300 |
The pcache is directed to certain situations to sequential reads. This concept
allows to drop parts of the cache that were already used, which will reduce
the size of cache and the number of displaced nodes.
Signed-off-by: Pavel Butsykin <address@hidden>
---
block/pcache.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/block/pcache.c b/block/pcache.c
index 40fa3f3..df4834a 100644
--- a/block/pcache.c
+++ b/block/pcache.c
@@ -83,6 +83,7 @@ typedef struct PCacheNode {
NODE_STATUS_REMOVE = 3,
NODE_STATUS_DELETED = 4, /* only for debugging */
} status;
+ uint64_t rdcnt;
int ref;
} PCacheNode;
@@ -142,10 +143,14 @@ static uint64_t ranges_overlap_size(uint64_t offset1,
uint64_t size1,
static void read_cache_data(PCacheAIOCBRead *acb, PCacheNode *node,
uint64_t offset, uint64_t bytes)
{
+ BDRVPCacheState *s = acb->bs->opaque;
uint64_t qiov_offs = 0, node_offs = 0;
uint64_t size;
uint64_t copy;
+ assert(node->status == NODE_STATUS_COMPLETED ||
+ node->status == NODE_STATUS_REMOVE);
+
if (offset < node->common.offset) {
qiov_offs = node->common.offset - offset;
} else {
@@ -156,6 +161,12 @@ static void read_cache_data(PCacheAIOCBRead *acb,
PCacheNode *node,
copy = qemu_iovec_from_buf(acb->qiov, qiov_offs,
node->data + node_offs, size);
+ node->rdcnt += size;
+ if (node->rdcnt >= node->common.bytes &&
+ node->status == NODE_STATUS_COMPLETED)
+ {
+ rbcache_remove(s->cache, &node->common);
+ }
assert(copy == size);
}
@@ -314,6 +325,7 @@ static RBCacheNode *pcache_node_alloc(uint64_t offset,
uint64_t bytes,
node->data = g_malloc(bytes);
node->status = NODE_STATUS_NEW;
+ node->rdcnt = 0;
node->ref = 1;
QTAILQ_INIT(&node->wait_list);
--
2.10.1
- [Qemu-devel] [PATCH v1 14/18] backup/pcache: pick up parts of the cache, (continued)
- [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, 2016/11/15
- [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 <=
- [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
[Qemu-devel] [PATCH v1 16/18] block/pcache: write through, Pavel Butsykin, 2016/11/15
Re: [Qemu-devel] [PATCH v1 00/18] I/O prefetch cache, no-reply, 2016/11/15