qemu/block
Kevin Wolf 92dcb59fd4 qcow2: Rewrite alloc_refcount_block/grow_refcount_table
The current implementation of alloc_refcount_block and grow_refcount_table has
fundamental problems regarding error handling. There are some places where an
I/O error means that the image is going to be corrupted. I have found that the
only way to fix this is to completely rewrite the thing.

In detail, the problem is that the refcount blocks itself are allocated using
alloc_refcount_noref (to avoid endless recursion when updating the refcount of
the new refcount block, which migh access just the same refcount block but its
allocation is not yet completed...). Only at the end of the refcount allocation
the refcount of the refcount block is increased. If an error happens in
between, the refcount block is in use, but has a refcount of zero and will
likely be overwritten later.

The new approach is explained in comments in the code. The trick is basically
to let new refcount blocks describe their own refcount, so their refcount will
be automatically changed when they are hooked up in the refcount table.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-02-23 13:23:29 -06:00
..
bochs.c Read-only device changed to opens it's file for read-only. 2010-01-26 15:42:01 -06:00
cloop.c Move block drivers into their own directory 2009-05-14 16:13:46 -05:00
cow.c block/cow.c: fix warnings with _FORTIFY_SOURCE 2010-01-26 14:59:20 -06:00
curl.c don't dereference NULL after failed strdup 2010-02-10 14:00:53 -06:00
dmg.c dmg: fix ->open failure 2010-01-11 13:41:00 -06:00
nbd.c block: kill BDRV_O_CREAT 2010-01-26 15:42:02 -06:00
parallels.c Read-only device changed to opens it's file for read-only. 2010-01-26 15:42:01 -06:00
qcow2-cluster.c qcow2: Fix access after end of array 2010-02-19 15:53:54 -06:00
qcow2-refcount.c qcow2: Rewrite alloc_refcount_block/grow_refcount_table 2010-02-23 13:23:29 -06:00
qcow2-snapshot.c qcow2: Don't ignore qcow2_alloc_clusters return value 2010-01-26 14:59:19 -06:00
qcow2.c qcow2: rename two QCowAIOCB members 2010-01-26 15:45:00 -06:00
qcow2.h qcow2: Fix signedness bugs 2010-02-10 11:56:57 -06:00
qcow.c block/qcow.c: fix warnings with _FORTIFY_SOURCE 2010-01-26 14:59:20 -06:00
raw-posix-aio.h Remove aio_ctx from paio_* interface 2009-10-30 08:39:34 -05:00
raw-posix.c block/raw-posix: Abort on pread beyond end of non-growable file 2010-01-26 16:41:07 -06:00
raw-win32.c block: kill BDRV_O_CREAT 2010-01-26 15:42:02 -06:00
vdi.c block/vdi: allow disk sizes not multiple of block size 2010-01-08 09:58:40 -06:00
vmdk.c block/vmdk.o: fix warnings with _FORTIFY_SOURCE 2010-01-26 14:59:20 -06:00
vpc.c Fix spelling in comment. 2009-09-09 14:57:20 -05:00
vvfat.c don't dereference NULL after failed strdup 2010-02-10 14:00:53 -06:00