Patchwork [1/2] qcow2: Clear L2 table cache after write error

login
register
mail settings
Submitter Kevin Wolf
Date May 20, 2010, 2:48 p.m.
Message ID <1274366923-30095-1-git-send-email-kwolf@redhat.com>
Download mbox | patch
Permalink /patch/53074/
State New
Headers show

Comments

Kevin Wolf - May 20, 2010, 2:48 p.m.
If the L2 table was already updated in cache, but writing it to disk has
failed, we must not continue using the changed version in the cache to stay
consistent with what's on the disk.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 block/qcow2-cluster.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

Patch

diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
index c11680d..ed5c4b2 100644
--- a/block/qcow2-cluster.c
+++ b/block/qcow2-cluster.c
@@ -696,6 +696,7 @@  int qcow2_alloc_cluster_link_l2(BlockDriverState *bs, QCowL2Meta *m)
 
     ret = write_l2_entries(bs, l2_table, l2_offset, l2_index, m->nb_clusters);
     if (ret < 0) {
+        qcow2_l2_cache_reset(bs);
         goto err;
     }