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.he...@gmail.com>
> Cc: Cyrill Gorcunov <gorcu...@gmail.com>
> Cc: Ingo Molnar <mi...@elte.hu>
> Cc: Kevin Wolf <kw...@redhat.com>
> Cc: Prasad Joshi <prasadjoshi...@gmail.com>
> Cc: Sasha Levin <levinsasha...@gmail.com>
> Signed-off-by: Pekka Enberg <penb...@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
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to