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>
This commit is contained in:
Dylan Reid 2018-07-12 18:05:34 -07:00 committed by chrome-bot
parent 6fd0c6f223
commit 5ad21740e4

View file

@ -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)
}