Patchwork [v2,1/2] sheepdog: don't update inode when create_and_write fails

login
register
mail settings
Submitter namei.unix@gmail.com
Date Dec. 17, 2012, 6:17 a.m.
Message ID <1355725047-5096-1-git-send-email-namei.unix@gmail.com>
Download mbox | patch
Permalink /patch/206783/
State New
Headers show

Comments

namei.unix@gmail.com - Dec. 17, 2012, 6:17 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 |    9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
MORITA Kazutaka - Dec. 17, 2012, 7:49 a.m.
At Mon, 17 Dec 2012 14:17:26 +0800,
Liu Yuan wrote:
> 
> 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 |    9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)

Reviewed-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Stefan Hajnoczi - Dec. 19, 2012, 2:25 p.m.
On Mon, Dec 17, 2012 at 02:17:26PM +0800, Liu Yuan wrote:
> 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 |    9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)

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

Stefan

Patch

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