Patchwork [v7,06/12] VMDK: flush multiple extents

login
register
mail settings
Submitter Feiran Zheng
Date July 3, 2011, 3:06 p.m.
Message ID <1309705612-27079-7-git-send-email-famcool@gmail.com>
Download mbox | patch
Permalink /patch/103013/
State New
Headers show

Comments

Feiran Zheng - July 3, 2011, 3:06 p.m.
Flush all the file that referenced by the image.

Signed-off-by: Fam Zheng <famcool@gmail.com>
---
 block/vmdk.c |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)

Patch

diff --git a/block/vmdk.c b/block/vmdk.c
index 32a9e2e..fbc8af5 100644
--- a/block/vmdk.c
+++ b/block/vmdk.c
@@ -1071,7 +1071,17 @@  static void vmdk_close(BlockDriverState *bs)
 
 static int vmdk_flush(BlockDriverState *bs)
 {
-    return bdrv_flush(bs->file);
+    int i, ret, err;
+    BDRVVmdkState *s = bs->opaque;
+
+    ret = bdrv_flush(bs->file);
+    for (i = 0; i < s->num_extents; i++) {
+        err = bdrv_flush(s->extents[i].file);
+        if (err < 0) {
+            ret = err;
+        }
+    }
+    return ret;
 }