From 5ad21740e4fbb4a10c1395396d058b85cd6c9dab Mon Sep 17 00:00:00 2001 From: Dylan Reid Date: Thu, 12 Jul 2018 18:05:34 -0700 Subject: [PATCH] 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 Reviewed-on: https://chromium-review.googlesource.com/1136019 Reviewed-by: Stephen Barber --- qcow/src/qcow.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/qcow/src/qcow.rs b/qcow/src/qcow.rs index 2052545dfb..d4cb6affb7 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) }