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

login
register
mail settings
Submitter namei.unix@gmail.com
Date July 25, 2013, 5:25 a.m.
Message ID <1374729935-27667-3-git-send-email-namei.unix@gmail.com>
Download mbox | patch
Permalink /patch/261589/
State New
Headers show

Comments

namei.unix@gmail.com - July 25, 2013, 5:25 a.m.
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@gmail.com>
---
 block/sheepdog.c |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Patch

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: