[sheepdog] [PATCH 2/2] sheepdog: put aio request into failed list when failing to send request

Liu Yuan namei.unix at gmail.com
Thu Jul 25 07:25:35 CEST 2013


qemu_co_send() in the add_aio_request might fail if connection is closed. In
this case we should it requests into failed list to be resended later when
connection is repaired.

Signed-off-by: Liu Yuan <namei.unix at gmail.com>
---
 block/sheepdog.c |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/block/sheepdog.c b/block/sheepdog.c
index 8c6c8f1..5bf78d0 100644
--- a/block/sheepdog.c
+++ b/block/sheepdog.c
@@ -1174,14 +1174,18 @@ static void coroutine_fn add_aio_request(BDRVSheepdogState *s, AIOReq *aio_req,
     /* send a header */
     ret = qemu_co_send(s->fd, &hdr, sizeof(hdr));
     if (ret < (int)sizeof(hdr)) {
-        error_report("failed to send a req, %s", strerror(errno));
+        dprintf("failed to send a req, %s", strerror(errno));
+        QLIST_REMOVE(aio_req, aio_siblings);
+        QLIST_INSERT_HEAD(&s->pending_aio_head, aio_req, aio_siblings);
         goto out;
     }
 
     if (wlen) {
         ret = qemu_co_sendv(s->fd, iov, niov, aio_req->iov_offset, wlen);
         if (ret < wlen) {
-            error_report("failed to send a data, %s", strerror(errno));
+            dprintf("failed to send a data, %s", strerror(errno));
+            QLIST_REMOVE(aio_req, aio_siblings);
+            QLIST_INSERT_HEAD(&s->pending_aio_head, aio_req, aio_siblings);
         }
     }
 out:
-- 
1.7.9.5




More information about the sheepdog mailing list