block: fix cache flushing in bdrv_commit
authorChristoph Hellwig <hch@lst.de>
Sun, 17 Jan 2010 11:32:30 +0000 (12:32 +0100)
committerAnthony Liguori <aliguori@us.ibm.com>
Wed, 20 Jan 2010 14:51:11 +0000 (08:51 -0600)
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
block.c

diff --git a/block.c b/block.c
index f90e9837da2f04aec8219ff12670d0bee62262f5..73c26ec410429fe5282dd66505246752bb015ea5 100644 (file)
--- a/block.c
+++ b/block.c
@@ -557,6 +557,7 @@ int bdrv_commit(BlockDriverState *bs)
     BlockDriver *drv = bs->drv;
     int64_t i, total_sectors;
     int n, j;
+    int ret = 0;
     unsigned char sector[512];
 
     if (!drv)
@@ -588,8 +589,10 @@ int bdrv_commit(BlockDriverState *bs)
         }
     }
 
-    if (drv->bdrv_make_empty)
-       return drv->bdrv_make_empty(bs);
+    if (drv->bdrv_make_empty) {
+        ret = drv->bdrv_make_empty(bs);
+        bdrv_flush(bs);
+    }
 
     /*
      * Make sure all data we wrote to the backing device is actually
@@ -597,7 +600,7 @@ int bdrv_commit(BlockDriverState *bs)
      */
     if (bs->backing_hd)
         bdrv_flush(bs->backing_hd);
-    return 0;
+    return ret;
 }
 
 /*