[Sheepdog] [PATCH 1/8] sheepdog: fix aio cancel

MORITA Kazutaka morita.kazutaka at lab.ntt.co.jp
Tue Apr 27 08:33:47 CEST 2010


Signed-off-by: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
---
 block/sheepdog.c |   11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/block/sheepdog.c b/block/sheepdog.c
index bfbd071..5c9a316 100644
--- a/block/sheepdog.c
+++ b/block/sheepdog.c
@@ -226,6 +226,7 @@ struct sd_aiocb {
 	void (*aio_done_func)(struct sd_aiocb *);
 
 	int write;
+	int canceled;
 
 	QLIST_HEAD(aioreq_head, aio_req) aioreq_head;
 };
@@ -376,7 +377,8 @@ static inline struct aio_req *get_req_from_id(struct bdrv_sd_state *s, int id)
 
 static void sd_finish_aiocb(struct sd_aiocb *acb)
 {
-	acb->common.cb(acb->common.opaque, acb->ret);
+	if (!acb->canceled)
+		acb->common.cb(acb->common.opaque, acb->ret);
 	qemu_aio_release(acb);
 }
 
@@ -390,11 +392,9 @@ static void sd_aio_bh_cb(void *opaque)
 
 static void sd_aio_cancel(BlockDriverAIOCB *blockacb)
 {
-	/* TODO: remove requests from aio_req_queue */
 	struct sd_aiocb *acb = (struct sd_aiocb *)blockacb;
-	QEMUBH *bh = qemu_bh_new(sd_aio_bh_cb, acb);
-	qemu_bh_cancel(bh);
-	qemu_aio_release(acb);
+
+	acb->canceled = 1;
 }
 
 static AIOPool sd_aio_pool = {
@@ -421,6 +421,7 @@ static struct sd_aiocb *sd_aio_setup(BlockDriverState *bs,
 
 	acb->aio_done_func = NULL;
 	acb->write = write;
+	acb->canceled = 0;
 	acb->bh = NULL;
 	acb->ret = 0;
 	QLIST_INIT(&acb->aioreq_head);
-- 
1.5.6.5




More information about the sheepdog mailing list