public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: Pekka Enberg <penberg@kernel.org>
Cc: kvm@vger.kernel.org, Asias He <asias.hejun@gmail.com>,
	Cyrill Gorcunov <gorcunov@gmail.com>, Ingo Molnar <mingo@elte.hu>,
	Prasad Joshi <prasadjoshi124@gmail.com>,
	Sasha Levin <levinsasha928@gmail.com>
Subject: Re: [RFC/PATCH] kvm tools, qcow: Add support for writing to zero refcount clusters
Date: Mon, 25 Jul 2011 10:11:46 +0200	[thread overview]
Message-ID: <4E2D2542.8040009@redhat.com> (raw)
In-Reply-To: <1311536709-25976-1-git-send-email-penberg@kernel.org>

Am 24.07.2011 21:45, schrieb Pekka Enberg:
> This patch adds support for writing to zero refcount clusters. Refcount blocks
> are cached in like L2 tables and flushed upon VIRTIO_BLK_T_FLUSH and when
> evicted from the LRU cache.
> 
> With this patch applied, 'qemu-img check' no longer complains about referenced
> clusters with zero reference count after
> 
>   dd if=/dev/zero of=/mnt/tmp
> 
> where '/mnt' is freshly generated QCOW2 image.
> 
> Cc: Asias He <asias.hejun@gmail.com>
> Cc: Cyrill Gorcunov <gorcunov@gmail.com>
> Cc: Ingo Molnar <mingo@elte.hu>
> Cc: Kevin Wolf <kwolf@redhat.com>
> Cc: Prasad Joshi <prasadjoshi124@gmail.com>
> Cc: Sasha Levin <levinsasha928@gmail.com>
> Signed-off-by: Pekka Enberg <penberg@kernel.org>

Looks okay, except that in case of a crash you'll most likely corrupt
the image because the order in which refcounts and mapping are written
out is completely undefined.

For a reliable implementation you need to make sure that for cluster
allocation you first write out the refcount update, then fsync, then
write out the mapping. Otherwise if the mapping is written out first and
then a crash happens, you'll have clusters that are used, but marked
free, so that in the next run a second cluster can be mapped to the same
location.

Kevin

  reply	other threads:[~2011-07-25  8:08 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-24 19:45 [RFC/PATCH] kvm tools, qcow: Add support for writing to zero refcount clusters Pekka Enberg
2011-07-25  8:11 ` Kevin Wolf [this message]
2011-07-28 10:43   ` Pekka Enberg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4E2D2542.8040009@redhat.com \
    --to=kwolf@redhat.com \
    --cc=asias.hejun@gmail.com \
    --cc=gorcunov@gmail.com \
    --cc=kvm@vger.kernel.org \
    --cc=levinsasha928@gmail.com \
    --cc=mingo@elte.hu \
    --cc=penberg@kernel.org \
    --cc=prasadjoshi124@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox