Statistics
| Branch: | Revision:

root / block / qcow2-cluster.c @ 7fa60fa3

History | View | Annotate | Download (27.9 kB)

# Date Author Comment
9e2a3701 06/15/2011 03:36 pm Kevin Wolf

qcow2: Fix in-flight list after qcow2_cache_put failure

If qcow2_cache_put returns an error during cluster allocation and the
allocation fails, it must be removed from the list of in-flight allocations.
Otherwise we'd get a loop in the list when the ACB is used for the next...

80fa3341 06/08/2011 12:56 pm Kevin Wolf

qcow2: Fix memory leaks in error cases

This fixes memory leaks that may be caused by I/O errors during L1 table growth
(can happen during save_vm) and in qemu-img check.

Signed-off-by: Kevin Wolf <>

16fde5f2 02/10/2011 02:24 pm Kevin Wolf

qcow2: Fix order in L2 table COW

When copying L2 tables (this happens only with internal snapshots), the order
wasn't completely safe, so that after a crash you could end up with a L2 table
that has too low refcount, possibly leading to corruption in the long run....

8af36488 02/10/2011 02:23 pm Kevin Wolf

qcow2: Fix error handling for reading compressed clusters

When reading a compressed cluster failed, qcow2 falsely returned success.

Signed-off-by: Kevin Wolf <>
Reviewed-by: Markus Armbruster <>

5ea929e3 01/31/2011 11:03 am Kevin Wolf

qcow2: Add bdrv_discard support

This adds a bdrv_discard function to qcow2 that frees the discarded clusters.
It does not yet pass the discard on to the underlying file system driver, but
the space can be reused by future writes to the image.

Signed-off-by: Kevin Wolf <>...

29c1a730 01/24/2011 05:41 pm Kevin Wolf

qcow2: Use QcowCache

Use the new functions of qcow2-cache.c for everything that works on refcount
block and L2 tables.

Signed-off-by: Kevin Wolf <>

3de0a294 01/24/2011 05:41 pm Kevin Wolf

qcow2: Batch flushes for COW

qcow2 calls bdrv_flush() after performing COW in order to ensure that the
L2 table change is never written before the copy is safe on disk. Now that the
L2 table is cached, we can wait with flushing until we write out the next L2...

653df36b 01/24/2011 12:08 pm Aurelien Jarno

qcow2: fix unaligned access

cpu_to_be64w() is called with an obviously non-aligned pointer. Use
cpu_to_be64wu() instead. It fixes unaligned accesses errors on IA64
hosts.

Cc: Kevin Wolf <>
Signed-off-by: Aurelien Jarno <>...

7c80ab3f 12/17/2010 05:15 pm Jes Sorensen

block/qcow2.c: rename qcow_ functions to qcow2_

It doesn't really make sense for functions in qcow2.c to be named
qcow_ so convert the names to match correctly.

Signed-off-by: Jes Sorensen <>
Signed-off-by: Kevin Wolf <>

1c02e2a1 11/04/2010 02:54 pm Kevin Wolf

qcow2: Invalidate cache after failed read

The cache content may be destroyed after a failed read, better not use it any
more.

Signed-off-by: Kevin Wolf <>
Reviewed-by: Stefan Hajnoczi <>

72893756 10/22/2010 03:49 pm Stefan Hajnoczi

qcow2: Support exact L1 table growth

The L1 table grow operation includes a size calculation that bumps up
the new L1 table size in order to anticipate the size needs of vmstate
data. This helps reduce the number of times that the L1 table has to be
grown when vmstate data is appended....

29216ed1 09/21/2010 04:39 pm Kevin Wolf

qcow2: Move sync out of qcow2_alloc_clusters

Signed-off-by: Kevin Wolf <>

9f8e668e 09/21/2010 04:39 pm Kevin Wolf

qcow2: Get rid of additional sync on COW

We always have a sync for the refcount update when a new cluster is
allocated. If we move this past the COW, we can save an additional sync.

Signed-off-by: Kevin Wolf <>

bd28f835 09/21/2010 04:39 pm Kevin Wolf

qcow2: Avoid bounce buffers for AIO read requests

qcow2 used to use bounce buffers for any AIO requests. This does not only imply
unnecessary copying, but also unbounded allocations which should be avoided.

This patch removes bounce buffers from the normal AIO read path, and constrains...

7ec5e6a4 09/08/2010 01:39 pm Kevin Wolf

qcow2: Remove unnecessary flush after L2 write

When a new cluster was allocated, we only need a flush after the write to the
L2 table if it was a COW and we need to decrease the refcounts of the old
clusters.

Signed-off-by: Kevin Wolf <>

8b3b7206 06/22/2010 03:38 pm Kevin Wolf

qcow2: Use bdrv_(p)write_sync for metadata writes

Use bdrv_(p)write_sync to ensure metadata integrity in case of a crash.

Signed-off-by: Kevin Wolf <>

68dba0bf 06/15/2010 10:41 am Kevin Wolf

qcow2: Restore L1 entry on l2_allocate failure

If writing the L1 table to disk failed, we need to restore its old content in
memory to avoid inconsistencies.

Reported-by: Juan Quintela <>
Signed-off-by: Kevin Wolf <>

55c17e98 05/28/2010 02:29 pm Kevin Wolf

qcow2: Change l2_load to return 0/-errno

Provide the error code to the caller instead of just indicating success/error.

Signed-off-by: Kevin Wolf <>

1c46efaa 05/28/2010 02:29 pm Kevin Wolf

qcow2: Allow qcow2_get_cluster_offset to return errors

qcow2_get_cluster_offset() looks up a given virtual disk offset and returns the
offset of the corresponding cluster in the image file. Errors (e.g. L2 table
can't be read) are currenctly indicated by a return value of 0, which is...

1b7c801b 05/28/2010 02:14 pm Kevin Wolf

qcow2: Clear L2 table cache after write error

If the L2 table was already updated in cache, but writing it to disk has
failed, we must not continue using the changed version in the cache to stay
consistent with what's on the disk.

Signed-off-by: Kevin Wolf <>

175e1152 05/28/2010 02:14 pm Kevin Wolf

qcow2: Fix error handling in l2_allocate

l2_allocate has some intermediate states in which the image is inconsistent.
Change the order to write to the L1 table only after the new L2 table has
successfully been initialized.

Also reset the L2 cache in failure case, it's very likely wrong....

66f82cee 05/03/2010 11:07 am Kevin Wolf

block: Open the underlying image file in generic code

Format drivers shouldn't need to bother with things like file names, but rather
just get an open BlockDriverState for the underlying protocol. This patch
introduces this behaviour for bdrv_open implementation. For protocols which...

8252278a 04/23/2010 05:08 pm Kevin Wolf

qcow2: Trigger blkdebug events

This adds blkdebug events to qcow2 to allow injecting I/O errors in specific
places.

Signed-off-by: Kevin Wolf <>

79a31189 04/23/2010 05:08 pm Kevin Wolf

qcow2: Return 0/-errno in write_l2_entries

Change write_l2_entries to return the real error code instead of -1.

Signed-off-by: Kevin Wolf <>

c835d00f 04/23/2010 05:08 pm Kevin Wolf

qcow2: Fix error return code in qcow2_alloc_cluster_link_l2

Fix qcow2_alloc_cluster_link_l2 to return the real error code like it does in
all other error cases.

Signed-off-by: Kevin Wolf <>

f7defcb6 04/23/2010 05:08 pm Kevin Wolf

qcow2: Return 0/-errno in write_l1_entry

Change write_l1_entry to return the real error code instead of -1.

Signed-off-by: Kevin Wolf <>

c46e1167 04/23/2010 05:08 pm Kevin Wolf

qcow2: Return 0/-errno in l2_allocate

Returning NULL on error doesn't allow distinguishing between different errors.
Change the interface to return an integer for -errno.

Signed-off-by: Kevin Wolf <>

c644db3d 04/10/2010 02:25 am Kevin Wolf

qcow2: Remove request from in-flight list after error

If we complete a request with a failure we need to remove it from the list of
requests that are in flight. If we don't do it, the next time the same AIOCB is
used for a cluster allocation it will create a loop in the list and qemu will...

4805bb66 02/19/2010 11:53 pm Kevin Wolf

qcow2: Fix access after end of array

If a write requests crosses a L2 table boundary and all clusters until the
end of the L2 table are usable for the request, we must not look at the next
L2 entry because we already have arrived at the end of the array....

f4f0d391 02/10/2010 07:56 pm Kevin Wolf

qcow2: Fix signedness bugs

Checking for return codes < 0 isn't really going to work with unsigned
types. Use signed types instead.

Signed-off-by: Kevin Wolf <>
Signed-off-by: Anthony Liguori <>

fb8fa77c 01/26/2010 10:59 pm Kevin Wolf

qcow2: Fix error handling in qcow2_grow_l1_table

Return the appropriate error value instead of always using EIO. Don't free the
L1 table on errors, we still need it.

Signed-off-by: Kevin Wolf <>
Signed-off-by: Anthony Liguori <>

1e3e8f1a 01/26/2010 10:59 pm Kevin Wolf

qcow2: Return 0/-errno in get_cluster_table

Switching to 0/-errno allows it to distinguish different error cases.

Signed-off-by: Kevin Wolf <>
Signed-off-by: Anthony Liguori <>

148da7ea 01/26/2010 10:59 pm Kevin Wolf

qcow2: Return 0/-errno in qcow2_alloc_cluster_offset

Returning 0/-errno allows it to distingush different errors classes. The
cluster offset of newly allocated clusters is now returned in the QCowL2Meta
struct.

Signed-off-by: Kevin Wolf <>...

5d757b56 01/26/2010 10:59 pm Kevin Wolf

qcow2: Don't ignore qcow2_alloc_clusters return value

Now that qcow2_alloc_clusters can return error codes, we must handle them in
the callers of qcow2_alloc_clusters.

Signed-off-by: Kevin Wolf <>
Signed-off-by: Anthony Liguori <>

d191d12d 11/09/2009 04:43 pm Stefan Weil

qcow2: Allow qcow2 disk images with size zero

Images with disk size 0 may be used for
VM snapshots, but not to save normal block data.

It is possible to create such images using
qemu-img, but opening them later fails.

So even "qemu-img info image.qcow2" is not...

72ecf02d 10/27/2009 07:28 pm Kevin Wolf

Revert "qcow2: Bring synchronous read/write back to life"

It was merely a workaround and the real fix is done now.
This reverts commit ef845c3bf421290153154635dc18eaa677cecb43.

Signed-off-by: Kevin Wolf <>
Signed-off-by: Anthony Liguori <>

ef845c3b 10/15/2009 05:32 pm Kevin Wolf

qcow2: Bring synchronous read/write back to life

When the synchronous read and write functions were dropped, they were replaced
by generic emulation functions. Unfortunately, these emulation functions don't
provide the same semantics as the original functions did....

80ee15a6 10/05/2009 05:32 pm Kevin Wolf

qcow2: Increase maximum cluster size to 2 MB

This patch increases the maximum qcow2 cluster size to 2 MB. Starting with 128k
clusters, L2 tables span 2 GB or more of virtual disk space, causing 32 bit
truncation and wraparound of signed integers. Therefore some variables need to...

72cf2d4f 09/12/2009 10:36 am Blue Swirl

Fix sys-queue.h conflict for good

Problem: Our file sys-queue.h is a copy of the BSD file, but there are
some additions and it's not entirely compatible. Because of that, there have
been conflicts with system headers on BSD systems. Some hacks have been
introduced in the commits 15cc9235840a22c289edbe064a9b3c19c5f49896,...

f214978a 09/10/2009 01:31 am Kevin Wolf

qcow2: Order concurrent AIO requests on the same unallocated cluster

When two AIO requests write to the same cluster, and this cluster is
unallocated, currently both requests allocate a new cluster and the second one
merges the first one when it is completed. This means an cluster allocation, a...

3f6a3ee5 07/10/2009 09:44 pm Kevin Wolf

qcow2: Fix L1 table memory allocation

Contrary to what one could expect, the size of L1 tables is not cluster
aligned. So as we're writing whole sectors now instead of single entries,
we need to ensure that the L1 table in memory is large enough; otherwise...

45aba42f 06/16/2009 11:18 pm Kevin Wolf

qcow2: Split out guest cluster functions

qcow2-cluster.c contains all functions related to the management of guest
clusters, i.e. what the guest sees on its virtual disk. This code is about
mapping these guest clusters to host clusters in the image file using the...

ed6ccf0f 06/16/2009 11:18 pm Kevin Wolf

qcow2: Rename global functions

The qcow2 source is now split into several more manageable files. During the
conversion quite some functions that were static before needed to be changed to
be global to make the source compile again.

We were lucky enough not to get name conflicts with these additional global...

6583e3c7 06/16/2009 11:18 pm Kevin Wolf

l2_allocate: Write complete sectors

When modifying the L1 table, l2_allocate() needs to write complete sectors
instead of single entries. The L1 table is already in memory, reading it from
disk in the block layer to align the request is wasted performance....

4c1612d9 06/16/2009 11:18 pm Kevin Wolf

alloc_cluster_link_l2: Write complete sectors

When updating the L2 tables in alloc_cluster_link_l2(), write complete
sectors instead of updating single entries.

Signed-off-by: Kevin Wolf <>
Signed-off-by: Anthony Liguori <>