Patchwork sheepdog: don't update inode when create_and_write fails

login
register
mail settings
Submitter namei.unix@gmail.com
Date Dec. 15, 2012, 9:52 a.m.
Message ID <1355565174-5121-1-git-send-email-namei.unix@gmail.com>
Download mbox | patch
Permalink /patch/206609/
State New
Headers show

Comments

namei.unix@gmail.com - Dec. 15, 2012, 9:52 a.m.
From: Liu Yuan <tailai.ly@taobao.com>

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 <morita.kazutaka@lab.ntt.co.jp>
Cc: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
---
 block/sheepdog.c |   12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

Patch

diff --git a/block/sheepdog.c b/block/sheepdog.c
index a48f58c..ef9e653 100644
--- a/block/sheepdog.c
+++ b/block/sheepdog.c
@@ -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) {
         /*