[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PATCH RFC v2 13/22] block/pcache: add generic request comp
From: |
Pavel Butsykin |
Subject: |
[Qemu-block] [PATCH RFC v2 13/22] block/pcache: add generic request complete |
Date: |
Mon, 29 Aug 2016 20:10:12 +0300 |
his change allow us to generalize the completion of all requests.
Signed-off-by: Pavel Butsykin <address@hidden>
---
block/pcache.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/block/pcache.c b/block/pcache.c
index 435f2b4..1ff4c6a 100644
--- a/block/pcache.c
+++ b/block/pcache.c
@@ -105,6 +105,7 @@ typedef struct PrefCacheAIOCB {
CoMutex lock;
uint32_t cnt;
} requests;
+ uint32_t ref;
QEMUBH *bh;
int ret;
} PrefCacheAIOCB;
@@ -505,9 +506,11 @@ static void pcache_aio_bh(void *opaque)
static void complete_aio_request(PrefCacheAIOCB *acb)
{
- acb->bh = aio_bh_new(bdrv_get_aio_context(acb->common.bs),
- pcache_aio_bh, acb);
- qemu_bh_schedule(acb->bh);
+ if (atomic_dec_fetch(&acb->ref) == 0) {
+ acb->bh = aio_bh_new(bdrv_get_aio_context(acb->common.bs),
+ pcache_aio_bh, acb);
+ qemu_bh_schedule(acb->bh);
+ }
}
static void pcache_node_submit(PrefCachePartReq *req)
@@ -585,9 +588,7 @@ static void pcache_aio_cb(void *opaque, int ret)
pcache_merge_requests(acb);
}
- acb->common.cb(acb->common.opaque, ret);
-
- qemu_aio_unref(acb);
+ complete_aio_request(acb);
}
static PrefCacheAIOCB *pcache_aio_get(BlockDriverState *bs, int64_t sector_num,
@@ -603,6 +604,7 @@ static PrefCacheAIOCB *pcache_aio_get(BlockDriverState *bs,
int64_t sector_num,
acb->requests.cnt = 0;
acb->qiov = qiov;
acb->aio_type = type;
+ acb->ref = 1;
acb->ret = 0;
QTAILQ_INIT(&acb->requests.list);
--
2.8.3
- [Qemu-block] [PATCH RFC v2 22/22] block/pcache: drop used pcache node, (continued)
- [Qemu-block] [PATCH RFC v2 22/22] block/pcache: drop used pcache node, Pavel Butsykin, 2016/08/29
- [Qemu-block] [PATCH RFC v2 02/22] block/pcache: add own AIOCB block, Pavel Butsykin, 2016/08/29
- [Qemu-block] [PATCH RFC v2 14/22] block/pcache: add support for rescheduling requests, Pavel Butsykin, 2016/08/29
- [Qemu-block] [PATCH RFC v2 05/22] block/pcache: add aio requests into cache, Pavel Butsykin, 2016/08/29
- [Qemu-block] [PATCH RFC v2 04/22] block/pcache: add pcache debug build, Pavel Butsykin, 2016/08/29
- [Qemu-block] [PATCH RFC v2 17/22] block/pcache: skip readahead for non-sequential requests, Pavel Butsykin, 2016/08/29
- [Qemu-block] [PATCH RFC v2 12/22] block/pcache: implement read cache to qiov and drop node during aio write, Pavel Butsykin, 2016/08/29
- [Qemu-block] [PATCH RFC v2 11/22] add QEMU style defines for __sync_add_and_fetch, Pavel Butsykin, 2016/08/29
- [Qemu-block] [PATCH RFC v2 03/22] util/rbtree: add rbtree from linux kernel, Pavel Butsykin, 2016/08/29
- [Qemu-block] [PATCH RFC v2 21/22] block/pcache: add write through node, Pavel Butsykin, 2016/08/29
- [Qemu-block] [PATCH RFC v2 13/22] block/pcache: add generic request complete,
Pavel Butsykin <=
- [Qemu-block] [PATCH RFC v2 19/22] block/pcache: add pcache node assert, Pavel Butsykin, 2016/08/29
- [Qemu-block] [PATCH RFC v2 01/22] block/pcache: empty pcache driver filter, Pavel Butsykin, 2016/08/29