]> xenbits.xensource.com Git - qemu-upstream-4.4-testing.git/commitdiff
qcow2: Move sync out of qcow2_alloc_clusters
authorKevin Wolf <kwolf@redhat.com>
Fri, 17 Sep 2010 14:57:48 +0000 (16:57 +0200)
committerKevin Wolf <kwolf@redhat.com>
Tue, 21 Sep 2010 13:39:42 +0000 (15:39 +0200)
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block/qcow2-cluster.c
block/qcow2-refcount.c
block/qcow2-snapshot.c

index f562b1602efa4107fe7416db9151c627756b77b6..818c0dbd4466bb0b81d0454cf122bbe56aa13b05 100644 (file)
@@ -60,6 +60,7 @@ int qcow2_grow_l1_table(BlockDriverState *bs, int min_size)
         qemu_free(new_l1_table);
         return new_l1_table_offset;
     }
+    bdrv_flush(bs->file);
 
     BLKDBG_EVENT(bs->file, BLKDBG_L1_GROW_WRITE_TABLE);
     for(i = 0; i < s->l1_size; i++)
@@ -243,6 +244,7 @@ static int l2_allocate(BlockDriverState *bs, int l1_index, uint64_t **table)
     if (l2_offset < 0) {
         return l2_offset;
     }
+    bdrv_flush(bs->file);
 
     /* allocate a new entry in the l2 cache */
 
@@ -863,6 +865,7 @@ int qcow2_alloc_cluster_offset(BlockDriverState *bs, uint64_t offset,
         QLIST_REMOVE(m, next_in_flight);
         return cluster_offset;
     }
+    bdrv_flush(bs->file);
 
     /* save info needed for meta data update */
     m->offset = offset;
index 4fc3f80a9e845a49197c2839f7c75048a5d7c068..7082601f598981ff55b90f70fd6a84f16f0f7aec 100644 (file)
@@ -629,8 +629,6 @@ int64_t qcow2_alloc_clusters(BlockDriverState *bs, int64_t size)
         return ret;
     }
 
-    bdrv_flush(bs->file);
-
     return offset;
 }
 
@@ -678,6 +676,8 @@ int64_t qcow2_alloc_bytes(BlockDriverState *bs, int size)
             goto redo;
         }
     }
+
+    bdrv_flush(bs->file);
     return offset;
 }
 
index 6228612f843cc64815e11ec0c365ba8038afbbed..bbfcaaae22a0db1094d93874e05565466ecf5155 100644 (file)
@@ -138,6 +138,7 @@ static int qcow_write_snapshots(BlockDriverState *bs)
     snapshots_size = offset;
 
     snapshots_offset = qcow2_alloc_clusters(bs, snapshots_size);
+    bdrv_flush(bs->file);
     offset = snapshots_offset;
     if (offset < 0) {
         return offset;
@@ -271,6 +272,7 @@ int qcow2_snapshot_create(BlockDriverState *bs, QEMUSnapshotInfo *sn_info)
     if (l1_table_offset < 0) {
         goto fail;
     }
+    bdrv_flush(bs->file);
 
     sn->l1_table_offset = l1_table_offset;
     sn->l1_size = s->l1_size;