From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58040) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WVzM0-0001G2-V3 for qemu-devel@nongnu.org; Fri, 04 Apr 2014 04:20:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WVzLv-0005if-Cm for qemu-devel@nongnu.org; Fri, 04 Apr 2014 04:20:00 -0400 Date: Fri, 4 Apr 2014 10:19:51 +0200 From: Stefan Hajnoczi Message-ID: <20140404081951.GC9801@stefanha-thinkpad.redhat.com> References: <1396532792-6399-1-git-send-email-kwolf@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1396532792-6399-1-git-send-email-kwolf@redhat.com> Subject: Re: [Qemu-devel] [PATCH] qcow2: Flush metadata during read-only reopen List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf Cc: qemu-devel@nongnu.org, qemu-stable@nongnu.org On Thu, Apr 03, 2014 at 03:46:32PM +0200, Kevin Wolf wrote: > 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 > --- > block/qcow2.c | 25 +++++++++++++++++++++---- > tests/qemu-iotests/039 | 20 ++++++++++++++++++++ > tests/qemu-iotests/039.out | 11 +++++++++++ > 3 files changed, 52 insertions(+), 4 deletions(-) Reviewed-by: Stefan Hajnoczi