]> git.ipfire.org Git - thirdparty/qemu.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)
committerMichael Roth <mdroth@linux.vnet.ibm.com>
Wed, 25 Jun 2014 20:34:50 +0000 (15:34 -0500)
commita8b7e73901487ed4f3e2794815945437585881af
tree6e8b9f71fb44ed1def83115428fd6ae1be93d568
parent38a55f30700346b8b53e52445eaaf6b0e579a17b
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>
(cherry picked from commit 4c2e5f8f46a17966dc45b5a3e07b97434c0eabdf)
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
block/qcow2.c
tests/qemu-iotests/039
tests/qemu-iotests/039.out