Patchwork [07/12] VMDK: vmdk_flush for extents

login
register
mail settings
Submitter Feiran Zheng
Date June 4, 2011, 12:42 a.m.
Message ID <BANLkTi=a6nba6R0J6q-KxVLLwGLFrEmM3w@mail.gmail.com>
Download mbox | patch
Permalink /patch/98702/
State New
Headers show

Comments

Feiran Zheng - June 4, 2011, 12:42 a.m.
Vmdk flush in extent array style.


Signed-off-by: Fam Zheng <famcool@gmail.com>
---
 block/vmdk.c |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)
Stefan Hajnoczi - June 18, 2011, 4:46 p.m.
On Sat, Jun 4, 2011 at 1:42 AM, Fam Zheng <famcool@gmail.com> wrote:
> Vmdk flush in extent array style.
>
>
> Signed-off-by: Fam Zheng <famcool@gmail.com>
> ---
>  block/vmdk.c |    9 ++++++++-
>  1 files changed, 8 insertions(+), 1 deletions(-)
>
> diff --git a/block/vmdk.c b/block/vmdk.c
> index f1233cf..1d74b62 100644
> --- a/block/vmdk.c
> +++ b/block/vmdk.c
> @@ -1094,7 +1094,14 @@ static void vmdk_close(BlockDriverState *bs)
>
>  static int vmdk_flush(BlockDriverState *bs)
>  {
> -    return bdrv_flush(bs->file);
> +    int i, ret;
> +    BDRVVmdkState *s = bs->opaque;
> +
> +    ret = bdrv_flush(bs->file);
> +    for (i = 0; i < s->num_extents; i++) {
> +        ret |= bdrv_flush(s->extents[i].file);

This could produce an invalid return code (e.g. ORing together two
different errnos).

I think the best you can do is:
for (...) {
    ret = bdrv_flush(s->extents[i].file);
    if (ret < 0) {
        err = ret;
    }
}
return err;

This loses multiple errnos but it doesn't have the potential to corrupt them.

Stefan

Patch

diff --git a/block/vmdk.c b/block/vmdk.c
index f1233cf..1d74b62 100644
--- a/block/vmdk.c
+++ b/block/vmdk.c
@@ -1094,7 +1094,14 @@  static void vmdk_close(BlockDriverState *bs)

 static int vmdk_flush(BlockDriverState *bs)
 {
-    return bdrv_flush(bs->file);
+    int i, ret;
+    BDRVVmdkState *s = bs->opaque;
+
+    ret = bdrv_flush(bs->file);
+    for (i = 0; i < s->num_extents; i++) {
+        ret |= bdrv_flush(s->extents[i].file);
+    }
+    return ret;
 }