summary refs log tree commit diff
path: root/qcow
diff options
context:
space:
mode:
authorDylan Reid <dgreid@chromium.org>2018-07-12 18:05:34 -0700
committerchrome-bot <chrome-bot@chromium.org>2018-07-13 17:28:52 -0700
commit5ad21740e4fbb4a10c1395396d058b85cd6c9dab (patch)
treeb630fd9cce237abe5d2d267d6021c45089088871 /qcow
parent6fd0c6f223b9337e9583b9cbce1cf1cab9872076 (diff)
downloadcrosvm-5ad21740e4fbb4a10c1395396d058b85cd6c9dab.tar
crosvm-5ad21740e4fbb4a10c1395396d058b85cd6c9dab.tar.gz
crosvm-5ad21740e4fbb4a10c1395396d058b85cd6c9dab.tar.bz2
crosvm-5ad21740e4fbb4a10c1395396d058b85cd6c9dab.tar.lz
crosvm-5ad21740e4fbb4a10c1395396d058b85cd6c9dab.tar.xz
crosvm-5ad21740e4fbb4a10c1395396d058b85cd6c9dab.tar.zst
crosvm-5ad21740e4fbb4a10c1395396d058b85cd6c9dab.zip
devices: block: sync after setting refcount
Make sure that the refcount update is commited to disk before we start
to write data to the cluster.

Change-Id: Ibdf5dde7a75c3582f87df46af1095c7dc0007d98
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1136019
Reviewed-by: Stephen Barber <smbarber@chromium.org>
Diffstat (limited to 'qcow')
-rw-r--r--qcow/src/qcow.rs2
1 files changed, 2 insertions, 0 deletions
diff --git a/qcow/src/qcow.rs b/qcow/src/qcow.rs
index 2052545..d4cb6af 100644
--- a/qcow/src/qcow.rs
+++ b/qcow/src/qcow.rs
@@ -411,6 +411,8 @@ impl QcowFile {
         self.file.sync_data()?;
         // The cluster refcount starts at one indicating it is used but doesn't need COW.
         self.set_cluster_refcount(new_addr, 1)?;
+        // Ensure that the refcount is updated before starting to use the cluster.
+        self.file.sync_data()?;
         Ok(new_addr)
     }