Skip to contentSkip to conversation

sheepdog: don't update inode when create_and_write fails

PATCH New Liu Yuan 3 participants 11 messages Dec 15, 2012 – Dec 19, 2012 Block layer

lore
Share & tools
lore

Liu Yuan

author
#0 lore raw

PATCH 1/1 sheepdog: don't update inode when create_and_write fails

From: Liu Yuan <[email protected]>

For the error case such as SD_RES_NO_SPACE, we shouldn't update the inode bitmap to avoid the scenario that the object is allocated but wasn't created at the server side. This will result in VM's IO error on the failed object.

Cc MORITA Kazutaka <[email protected]>
Cc Kevin Wolf <[email protected]>
---
 block/sheepdog.c |   12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
block/sheepdog.c +7 -5
index a48f58c..ef9e653 100644
@@ -697,6 +697,12 @@ static void coroutine_fn aio_read_response(void *opaque)
 
     acb = aio_req->aiocb;
 
+    if (rsp.result != SD_RES_SUCCESS) {
+        acb->ret = -EIO;
+        error_report("%s", sd_strerror(rsp.result));
+	goto err;
+    }
+
     switch (acb->aiocb_type) {
     case AIOCB_WRITE_UDATA:
         /* this coroutine context is no longer suitable for co_recv
@@ -736,11 +742,7 @@ static void coroutine_fn aio_read_response(void *opaque)
         break;
     }
 
-    if (rsp.result != SD_RES_SUCCESS) {
-        acb->ret = -EIO;
-        error_report("%s", sd_strerror(rsp.result));
-    }
-
+err:
     free_aio_req(s, aio_req);
     if (!acb->nr_pending) {
         /*
Signature · 1 line
1.7.9.5
author
#1 lore raw

PATCH 1/1 sheepdog: don't update inode when create_and_write fails

From: Liu Yuan <[email protected]>

For the error case such as SD_RES_NO_SPACE, we shouldn't update the inode bitmap to avoid the scenario that the object is allocated but wasn't created at the server side. This will result in VM's IO error on the failed object.

Cc MORITA Kazutaka <[email protected]>
Cc Kevin Wolf <[email protected]>
---
 block/sheepdog.c |   12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
block/sheepdog.c +7 -5
index a48f58c..6116316 100644
@@ -697,6 +697,12 @@ static void coroutine_fn aio_read_response(void *opaque)
 
     acb = aio_req->aiocb;
 
+    if (rsp.result != SD_RES_SUCCESS) {
+        acb->ret = -EIO;
+        error_report("%s", sd_strerror(rsp.result));
+        goto err;
+    }
+
     switch (acb->aiocb_type) {
     case AIOCB_WRITE_UDATA:
         /* this coroutine context is no longer suitable for co_recv
@@ -736,11 +742,7 @@ static void coroutine_fn aio_read_response(void *opaque)
         break;
     }
 
-    if (rsp.result != SD_RES_SUCCESS) {
-        acb->ret = -EIO;
-        error_report("%s", sd_strerror(rsp.result));
-    }
-
+err:
     free_aio_req(s, aio_req);
     if (!acb->nr_pending) {
         /*
Signature · 1 line
1.7.9.5
author
#2 lore raw

PATCH 1/1 sheepdog: don't update inode when create_and_write fails

In reply to Liu Yuan

From: Liu Yuan <[email protected]>

For the error case such as SD_RES_NO_SPACE, we shouldn't update the inode bitmap to avoid the scenario that the object is allocated but wasn't created at the server side. This will result in VM's IO error on the failed object.

Cc MORITA Kazutaka <[email protected]>
Cc Kevin Wolf <[email protected]>

---
Update
- update the coding style and passed checkpath

 block/sheepdog.c |   12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
block/sheepdog.c +7 -5
index a48f58c..6116316 100644
@@ -697,6 +697,12 @@ static void coroutine_fn aio_read_response(void *opaque)
 
     acb = aio_req->aiocb;
 
+    if (rsp.result != SD_RES_SUCCESS) {
+        acb->ret = -EIO;
+        error_report("%s", sd_strerror(rsp.result));
+        goto err;
+    }
+
     switch (acb->aiocb_type) {
     case AIOCB_WRITE_UDATA:
         /* this coroutine context is no longer suitable for co_recv
@@ -736,11 +742,7 @@ static void coroutine_fn aio_read_response(void *opaque)
         break;
     }
 
-    if (rsp.result != SD_RES_SUCCESS) {
-        acb->ret = -EIO;
-        error_report("%s", sd_strerror(rsp.result));
-    }
-
+err:
     free_aio_req(s, aio_req);
     if (!acb->nr_pending) {
         /*
Signature · 1 line
1.7.9.5
#3 lore raw

At Sat, 15 Dec 2012 17:59:12 +0800,

Quoted 37 lines · Liu Yuan

From: Liu Yuan <[email protected]>

For the error case such as SD_RES_NO_SPACE, we shouldn't update the inode bitmap to avoid the scenario that the object is allocated but wasn't created at the server side. This will result in VM's IO error on the failed object.

Cc MORITA Kazutaka <[email protected]>
Cc Kevin Wolf <[email protected]>

---
Update
- update the coding style and passed checkpath

 block/sheepdog.c |   12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
block/sheepdog.c +6 -0
index a48f58c..6116316 100644
@@ -697,6 +697,12 @@ static void coroutine_fn aio_read_response(void *opaque)
 
     acb = aio_req->aiocb;
 
+    if (rsp.result != SD_RES_SUCCESS) {
+        acb->ret = -EIO;
+        error_report("%s", sd_strerror(rsp.result));
+        goto err;
+    }
+
     switch (acb->aiocb_type) {
     case AIOCB_WRITE_UDATA:
         /* this coroutine context is no longer suitable for co_recv
@@ -736,11 +742,7 @@ static void coroutine_fn aio_read_response(void *opaque)
         break;
     }

block/sheepdog.c static void coroutine_fn aio_read_response(void *opaque) · line 748

Quoted 10 lines
block/sheepdog.c +1 -5
 
-    if (rsp.result != SD_RES_SUCCESS) {
-        acb->ret = -EIO;
-        error_report("%s", sd_strerror(rsp.result));
-    }
-
+err:
     free_aio_req(s, aio_req);
     if (!acb->nr_pending) {
         /*

send_pending_req() needs to be called even in error case. Rather than moving the error check, I think it looks better to update s->inode.data_vdi_id only when rsp.result is SD_RES_SUCCESS.

Thanks,

Kazutaka

author
#4 lore raw
Quoted 3 lines · MORITA Kazutaka

send_pending_req() needs to be called even in error case. Rather than moving the error check, I think it looks better to update s->inode.data_vdi_id only when rsp.result is SD_RES_SUCCESS.

Why can't we check the rsp.result in the first place? double check rsp.result inside one function looks a little bit complicated to me.

How about
+ if (rsp.result != SD_RES_SUCCESS) {

+        acb->ret = -EIO;
+        error_report("%s", sd_strerror(rsp.result));
+        send_pending_req(s, aio_req->oid);
+        goto err;

+
+ }

By the way, seems that
send_pending_req(s, vid_to_data_oid(s->inode.vdi_id, idx));
can be reduced to
send_pending_req(s, aio_req->oid);

If yes, I can send another patch to fix.

Thanks,
Yuan

#5 lore raw

At Mon, 17 Dec 2012 13:22:31 +0800,

Quoted 10 lines · Liu Yuan
Quoted 3 lines · MORITA Kazutaka

send_pending_req() needs to be called even in error case. Rather than moving the error check, I think it looks better to update s->inode.data_vdi_id only when rsp.result is SD_RES_SUCCESS.

Why can't we check the rsp.result in the first place? double check rsp.result inside one function looks a little bit complicated to me.

How about

block/sheepdog.c static void coroutine_fn aio_read_response(void *opaque)

Quoted 7 lines
block/sheepdog.c +7 -0
+    if (rsp.result != SD_RES_SUCCESS) {
+        acb->ret = -EIO;
+        error_report("%s", sd_strerror(rsp.result));
+        send_pending_req(s, aio_req->oid);
+        goto err;
+
+    }

Either is okay, but "s->co_recv = NULL" is necessary before send_pending_req() because we can receive another response while sending pending requests. In addition, it is better to call send_pending_req() only when we update inode; in most cases, we don't need to traverse pending list.

Quoted 7 lines

By the way, seems that
send_pending_req(s, vid_to_data_oid(s->inode.vdi_id, idx));
can be reduced to
send_pending_req(s, aio_req->oid);

If yes, I can send another patch to fix.

Looks correct.

Thanks,

Kazutaka

author
#7 lore raw

PATCH v2 2/2 sheepdog: pass oid directly to send_pending_req()

In reply to Liu Yuan

From: Liu Yuan <[email protected]>

Cc MORITA Kazutaka <[email protected]>
Cc Kevin Wolf <[email protected]>
---
 block/sheepdog.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
block/sheepdog.c +1 -1
index ef7bc81..ceabc00 100644
@@ -724,7 +724,7 @@ static void coroutine_fn aio_read_response(void *opaque)
              * create requests are not allowed, so we search the
              * pending requests here.
              */
-            send_pending_req(s, vid_to_data_oid(s->inode.vdi_id, idx));
+            send_pending_req(s, aio_req->oid);
         }
         break;
     case AIOCB_READ_UDATA:
Signature · 1 line
1.7.9.5
author
#6 lore raw

PATCH v2 1/2 sheepdog: don't update inode when create_and_write fails

In reply to Liu Yuan

From: Liu Yuan <[email protected]>

For the error case such as SD_RES_NO_SPACE, we shouldn't update the inode bitmap to avoid the scenario that the object is allocated but wasn't created at the server side. This will result in VM's IO error on the failed object.

Cc MORITA Kazutaka <[email protected]>
Cc Kevin Wolf <[email protected]>
---
 block/sheepdog.c |    9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
block/sheepdog.c +5 -4
index a48f58c..ef7bc81 100644
@@ -714,10 +714,11 @@ static void coroutine_fn aio_read_response(void *opaque)
              * and max_dirty_data_idx are changed to include updated
              * index between them.
              */
-            s->inode.data_vdi_id[idx] = s->inode.vdi_id;
-            s->max_dirty_data_idx = MAX(idx, s->max_dirty_data_idx);
-            s->min_dirty_data_idx = MIN(idx, s->min_dirty_data_idx);
-
+            if (rsp.result == SD_RES_SUCCESS) {
+                s->inode.data_vdi_id[idx] = s->inode.vdi_id;
+                s->max_dirty_data_idx = MAX(idx, s->max_dirty_data_idx);
+                s->min_dirty_data_idx = MIN(idx, s->min_dirty_data_idx);
+            }
             /*
              * Some requests may be blocked because simultaneous
              * create requests are not allowed, so we search the
Signature · 1 line
1.7.9.5
Reviewed-by on v2 2/2
#8 lore raw

Re: [Qemu-devel] [PATCH v2 2/2] sheepdog: pass oid directly to send_pending_req()

In reply to Liu Yuan

At Mon, 17 Dec 2012 14:17:27 +0800,

Quoted 9 lines · Liu Yuan

From: Liu Yuan <[email protected]>

Cc MORITA Kazutaka <[email protected]>
Cc Kevin Wolf <[email protected]>
---
 block/sheepdog.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Reviewed-by on v2 1/2
#9 lore raw
In reply to Liu Yuan

At Mon, 17 Dec 2012 14:17:26 +0800,

Quoted 7 lines · Liu Yuan

From: Liu Yuan <[email protected]>

For the error case such as SD_RES_NO_SPACE, we shouldn't update the inode bitmap to avoid the scenario that the object is allocated but wasn't created at the server side. This will result in VM's IO error on the failed object.

Quoted 6 lines
Cc MORITA Kazutaka <[email protected]>
Cc Kevin Wolf <[email protected]>
---
 block/sheepdog.c |    9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
#10 lore raw
In reply to Liu Yuan
Quoted 6 lines · Liu Yuan

From: Liu Yuan <[email protected]>

For the error case such as SD_RES_NO_SPACE, we shouldn't update the inode bitmap to avoid the scenario that the object is allocated but wasn't created at the server side. This will result in VM's IO error on the failed object.

Quoted 6 lines
Cc MORITA Kazutaka <[email protected]>
Cc Kevin Wolf <[email protected]>
---
 block/sheepdog.c |    9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

Thanks, applied to the block tree:
https://github.com/stefanha/qemu/commits/block

Stefan