]> rtime.felk.cvut.cz Git - lisovros/qemu_apohw.git/commit
qcow2: Flush metadata during read-only reopen
authorKevin Wolf <kwolf@redhat.com>
Thu, 3 Apr 2014 11:47:50 +0000 (13:47 +0200)
committerKevin Wolf <kwolf@redhat.com>
Fri, 4 Apr 2014 12:12:26 +0000 (14:12 +0200)
commit4c2e5f8f46a17966dc45b5a3e07b97434c0eabdf
treeaa545165b570b6c297d75dd0ae623abd3861e4f1
parentcbee81f6de57ddc1b21ba28f01f6a3b5d87428a5
qcow2: Flush metadata during read-only reopen

If lazy refcounts are enabled for a backing file, committing to this
backing file may leave it in a dirty state even if the commit succeeds.
The reason is that the bdrv_flush() call in bdrv_commit() doesn't flush
refcount updates with lazy refcounts enabled, and qcow2_reopen_prepare()
doesn't take care to flush metadata.

In order to fix this, this patch also fixes qcow2_mark_clean(), which
contains another ineffective bdrv_flush() call beause lazy refcounts are
disabled only afterwards. All existing callers of qcow2_mark_clean()
either don't modify refcounts or already flush manually, so that this
fixes only a latent, but not yet actually triggerable bug.

Another instance of the same problem is live snapshots. Again, a real
corruption is prevented by an explicit flush for non-read-only images in
external_snapshot_prepare(), but images using lazy refcounts stay dirty.

Cc: qemu-stable@nongnu.org
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
block/qcow2.c
tests/qemu-iotests/039
tests/qemu-iotests/039.out