[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v1 11/18] block/pcache: cache invalidation on AIO wr
From: |
Pavel Butsykin |
Subject: |
[Qemu-devel] [PATCH v1 11/18] block/pcache: cache invalidation on AIO write requests |
Date: |
Tue, 15 Nov 2016 09:37:08 +0300 |
In AIO write request completion we just drop all the intersecting nodes in the
cache, it's a simple way to keep the cache up-to-date.
Signed-off-by: Pavel Butsykin <address@hidden>
---
block/pcache.c | 39 ++++++++++++++++++++++++++++++++++++++-
1 file changed, 38 insertions(+), 1 deletion(-)
diff --git a/block/pcache.c b/block/pcache.c
index 1f3800d..27ee6dd 100644
--- a/block/pcache.c
+++ b/block/pcache.c
@@ -362,15 +362,52 @@ out:
return acb.ret;
}
+static void pcache_aio_write_cb(void *opaque, int ret)
+{
+ PCacheAIOCB *acb = opaque;
+ BDRVPCacheState *s = acb->bs->opaque;
+ uint64_t offset = acb->offset;
+ uint64_t bytes = acb->bytes;
+ uint64_t end_offs = offset + bytes;
+
+ if (ret < 0) {
+ goto out;
+ }
+
+ do {
+ PCacheNode *node = rbcache_search(s->cache, offset, bytes);
+ if (node == NULL) {
+ break;
+ }
+ assert(node->status == NODE_STATUS_COMPLETED ||
+ node->status == NODE_STATUS_INFLIGHT ||
+ node->status == NODE_STATUS_REMOVE);
+
+ offset = node->common.offset + node->common.bytes;
+ bytes = end_offs - offset;
+
+ if (node->status == NODE_STATUS_COMPLETED) {
+ rbcache_remove(s->cache, &node->common);
+ }
+ } while (end_offs > offset);
+
+out:
+ acb->ret = ret;
+ qemu_coroutine_enter(acb->co);
+}
+
static coroutine_fn int pcache_co_pwritev(BlockDriverState *bs, uint64_t
offset,
uint64_t bytes, QEMUIOVector *qiov,
int flags)
{
PCacheAIOCB acb = {
.co = qemu_coroutine_self(),
+ .bs = bs,
+ .offset = offset,
+ .bytes = bytes,
};
- bdrv_aio_pwritev(bs->file, offset, qiov, bytes, pcache_aio_cb, &acb);
+ bdrv_aio_pwritev(bs->file, offset, qiov, bytes, pcache_aio_write_cb, &acb);
qemu_coroutine_yield();
--
2.10.1
- Re: [Qemu-devel] [PATCH v1 05/18] tests/test-rbcache: add test cases, (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 <=
- [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
[Qemu-devel] [PATCH v1 16/18] block/pcache: write through, Pavel Butsykin, 2016/11/15