[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 27/30] sheepdog: check simultaneous create in resend_
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 27/30] sheepdog: check simultaneous create in resend_aioreq |
Date: |
Thu, 31 Oct 2013 16:48:41 +0100 |
From: MORITA Kazutaka <address@hidden>
After reconnection happens, all the inflight requests are moved to the
failed request list. As a result, sd_co_rw_vector() can send another
create request before resend_aioreq() resends a create request from
the failed list.
This patch adds a helper function check_simultaneous_create() and
checks simultaneous create requests more strictly in resend_aioreq().
Signed-off-by: MORITA Kazutaka <address@hidden>
Tested-by: Liu Yuan <address@hidden>
Reviewed-by: Liu Yuan <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
block/sheepdog.c | 64 ++++++++++++++++++++++++++++----------------------------
1 file changed, 32 insertions(+), 32 deletions(-)
diff --git a/block/sheepdog.c b/block/sheepdog.c
index eebb5fe..ef387de 100644
--- a/block/sheepdog.c
+++ b/block/sheepdog.c
@@ -1288,6 +1288,29 @@ out:
return ret;
}
+/* Return true if the specified request is linked to the pending list. */
+static bool check_simultaneous_create(BDRVSheepdogState *s, AIOReq *aio_req)
+{
+ AIOReq *areq;
+ QLIST_FOREACH(areq, &s->inflight_aio_head, aio_siblings) {
+ if (areq != aio_req && areq->oid == aio_req->oid) {
+ /*
+ * Sheepdog cannot handle simultaneous create requests to the same
+ * object, so we cannot send the request until the previous request
+ * finishes.
+ */
+ DPRINTF("simultaneous create to %" PRIx64 "\n", aio_req->oid);
+ aio_req->flags = 0;
+ aio_req->base_oid = 0;
+ QLIST_REMOVE(aio_req, aio_siblings);
+ QLIST_INSERT_HEAD(&s->pending_aio_head, aio_req, aio_siblings);
+ return true;
+ }
+ }
+
+ return false;
+}
+
static void coroutine_fn resend_aioreq(BDRVSheepdogState *s, AIOReq *aio_req)
{
SheepdogAIOCB *acb = aio_req->aiocb;
@@ -1296,29 +1319,19 @@ static void coroutine_fn
resend_aioreq(BDRVSheepdogState *s, AIOReq *aio_req)
/* check whether this request becomes a CoW one */
if (acb->aiocb_type == AIOCB_WRITE_UDATA && is_data_obj(aio_req->oid)) {
int idx = data_oid_to_idx(aio_req->oid);
- AIOReq *areq;
- if (s->inode.data_vdi_id[idx] == 0) {
- create = true;
- goto out;
- }
if (is_data_obj_writable(&s->inode, idx)) {
goto out;
}
- /* link to the pending list if there is another CoW request to
- * the same object */
- QLIST_FOREACH(areq, &s->inflight_aio_head, aio_siblings) {
- if (areq != aio_req && areq->oid == aio_req->oid) {
- DPRINTF("simultaneous CoW to %" PRIx64 "\n", aio_req->oid);
- QLIST_REMOVE(aio_req, aio_siblings);
- QLIST_INSERT_HEAD(&s->pending_aio_head, aio_req, aio_siblings);
- return;
- }
+ if (check_simultaneous_create(s, aio_req)) {
+ return;
}
- aio_req->base_oid = vid_to_data_oid(s->inode.data_vdi_id[idx], idx);
- aio_req->flags |= SD_FLAG_CMD_COW;
+ if (s->inode.data_vdi_id[idx]) {
+ aio_req->base_oid = vid_to_data_oid(s->inode.data_vdi_id[idx],
idx);
+ aio_req->flags |= SD_FLAG_CMD_COW;
+ }
create = true;
}
out:
@@ -1945,27 +1958,14 @@ static int coroutine_fn sd_co_rw_vector(void *p)
}
aio_req = alloc_aio_req(s, acb, oid, len, offset, flags, old_oid,
done);
+ QLIST_INSERT_HEAD(&s->inflight_aio_head, aio_req, aio_siblings);
if (create) {
- AIOReq *areq;
- QLIST_FOREACH(areq, &s->inflight_aio_head, aio_siblings) {
- if (areq->oid == oid) {
- /*
- * Sheepdog cannot handle simultaneous create
- * requests to the same object. So we cannot send
- * the request until the previous request
- * finishes.
- */
- aio_req->flags = 0;
- aio_req->base_oid = 0;
- QLIST_INSERT_HEAD(&s->pending_aio_head, aio_req,
- aio_siblings);
- goto done;
- }
+ if (check_simultaneous_create(s, aio_req)) {
+ goto done;
}
}
- QLIST_INSERT_HEAD(&s->inflight_aio_head, aio_req, aio_siblings);
add_aio_request(s, aio_req, acb->qiov->iov, acb->qiov->niov, create,
acb->aiocb_type);
done:
--
1.8.1.4
- [Qemu-devel] [PULL 16/30] block: Avoid unecessary drv->bdrv_getlength() calls, (continued)
- [Qemu-devel] [PULL 16/30] block: Avoid unecessary drv->bdrv_getlength() calls, Kevin Wolf, 2013/10/31
- [Qemu-devel] [PULL 17/30] qemu-iotests: Fix 051 reference output, Kevin Wolf, 2013/10/31
- [Qemu-devel] [PULL 18/30] qemu-iotests: drop duplicated "create_image", Kevin Wolf, 2013/10/31
- [Qemu-devel] [PULL 19/30] qemu-iotests: Test case for backing file deletion, Kevin Wolf, 2013/10/31
- [Qemu-devel] [PULL 20/30] sheepdog: check return values of qemu_co_recv/send correctly, Kevin Wolf, 2013/10/31
- [Qemu-devel] [PULL 21/30] sheepdog: handle vdi objects in resend_aio_req, Kevin Wolf, 2013/10/31
- [Qemu-devel] [PULL 22/30] sheepdog: reload inode outside of resend_aioreq, Kevin Wolf, 2013/10/31
- [Qemu-devel] [PULL 23/30] coroutine: add co_aio_sleep_ns() to allow sleep in block drivers, Kevin Wolf, 2013/10/31
- [Qemu-devel] [PULL 24/30] sheepdog: try to reconnect to sheepdog after network error, Kevin Wolf, 2013/10/31
- [Qemu-devel] [PULL 25/30] sheepdog: make add_aio_request and send_aioreq void functions, Kevin Wolf, 2013/10/31
- [Qemu-devel] [PULL 27/30] sheepdog: check simultaneous create in resend_aioreq,
Kevin Wolf <=
- [Qemu-devel] [PULL 26/30] sheepdog: cancel aio requests if possible, Kevin Wolf, 2013/10/31
- [Qemu-devel] [PULL 28/30] qemu-iotests: prefill some data to test image, Kevin Wolf, 2013/10/31
- [Qemu-devel] [PULL 29/30] qapi: Add optional field 'compressed' to ImageInfo, Kevin Wolf, 2013/10/31
- [Qemu-devel] [PULL 30/30] vmdk: Implment bdrv_get_specific_info, Kevin Wolf, 2013/10/31
- Re: [Qemu-devel] [PULL v2 00/30] Block patches, Anthony Liguori, 2013/10/31