Patchwork [1/6] qcow2: flush refcount cache correctly in alloc_refcount_block()

login
register
mail settings
Submitter Stefan Hajnoczi
Date Feb. 19, 2013, 3:45 p.m.
Message ID <1361288706-13929-2-git-send-email-stefanha@redhat.com>
Download mbox | patch
Permalink /patch/221715/
State New
Headers show

Comments

Stefan Hajnoczi - Feb. 19, 2013, 3:45 p.m.
update_refcount() affects the refcount cache, it does not write to disk.
Therefore bdrv_flush(bs->file) does nothing.  We need to flush the
refcount cache in order to write out the refcount updates!

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 block/qcow2-refcount.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Patch

diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c
index bc1784c..05b5ec9 100644
--- a/block/qcow2-refcount.c
+++ b/block/qcow2-refcount.c
@@ -237,7 +237,7 @@  static int alloc_refcount_block(BlockDriverState *bs,
             goto fail_block;
         }
 
-        bdrv_flush(bs->file);
+        qcow2_cache_flush(bs, s->refcount_block_cache);
 
         /* Initialize the new refcount block only after updating its refcount,
          * update_refcount uses the refcount cache itself */