History | View | Annotate | Download (27 kB)
qcow2: avoid reentrant bdrv_read() in copy_sectors()
A BlockDriverState should not issue requests on itself through thepublic block layer interface. Nested, or reentrant, requests areproblematic because they do I/O throttling and request tracking twice....
qcow2: Unlock during COW
Unlocking during COW allows for more parallelism. One change it requires isthat buffers are dynamically allocated instead of just using a per-imagebuffer.
While touching the code, drop the synchronous qcow2_read() function and replace...
qcow2: Fix bdrv_write_compressed error handling
If during allocation of compressed clusters the cluster was already allocateduncompressed, fail and properly release the l2_table (the latter avoids afailed assertion).
While at it, make it return some real error numbers instead of -1....
qcow2: initialize metadata before inserting in cluster_allocs
QCow2Meta structure was inserted into list before many fields areinitialized. Currently is not a problem cause all occur in a lockbut if qcow2_alloc_clusters would in a future unlock this lock...
qcow2: fix range check
QCowL2Meta::offset is not cluster aligned but only sector alignedhowever nb_clusters count cluster from cluster start.This fix range check. Note that old code have no corruption issuesrelated to this check cause it only cause intersection to occur...
qcow2: removed unused depends_on field
Signed-off-by: Frediano Ziglio <freddy77@gmail.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
qcow2: use always stderr for debugging
let all DEBUG_ALLOC2 printf goes to stderr
qcow2: fix typo in documentation for qcow2_get_cluster_offset()
Documentation states the num is measured in clusters, but itsactually measured in sectors
Signed-off-by: Devin Nakamura <devin122@gmail.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Use glib memory allocation and free functions
qemu_malloc/qemu_free no longer exist after this commit.
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
qcow2: Use coroutines
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
qcow2: Fix in-flight list after qcow2_cache_put failure
If qcow2_cache_put returns an error during cluster allocation and theallocation 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...
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.
qcow2: Fix order in L2 table COW
When copying L2 tables (this happens only with internal snapshots), the orderwasn't completely safe, so that after a crash you could end up with a L2 tablethat has too low refcount, possibly leading to corruption in the long run....
qcow2: Fix error handling for reading compressed clusters
When reading a compressed cluster failed, qcow2 falsely returned success.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>Reviewed-by: Markus Armbruster <armbru@redhat.com>
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, butthe space can be reused by future writes to the image.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>...
qcow2: Use QcowCache
Use the new functions of qcow2-cache.c for everything that works on refcountblock and L2 tables.
qcow2: Batch flushes for COW
qcow2 calls bdrv_flush() after performing COW in order to ensure that theL2 table change is never written before the copy is safe on disk. Now that theL2 table is cached, we can wait with flushing until we write out the next L2...
qcow2: fix unaligned access
cpu_to_be64w() is called with an obviously non-aligned pointer. Usecpu_to_be64wu() instead. It fixes unaligned accesses errors on IA64hosts.
Cc: Kevin Wolf <kwolf@redhat.com>Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>...
block/qcow2.c: rename qcow_ functions to qcow2_
It doesn't really make sense for functions in qcow2.c to be namedqcow_ so convert the names to match correctly.
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
qcow2: Invalidate cache after failed read
The cache content may be destroyed after a failed read, better not use it anymore.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
qcow2: Support exact L1 table growth
The L1 table grow operation includes a size calculation that bumps upthe new L1 table size in order to anticipate the size needs of vmstatedata. This helps reduce the number of times that the L1 table has to begrown when vmstate data is appended....
qcow2: Move sync out of qcow2_alloc_clusters
qcow2: Get rid of additional sync on COW
We always have a sync for the refcount update when a new cluster isallocated. If we move this past the COW, we can save an additional sync.
qcow2: Avoid bounce buffers for AIO read requests
qcow2 used to use bounce buffers for any AIO requests. This does not only implyunnecessary copying, but also unbounded allocations which should be avoided.
This patch removes bounce buffers from the normal AIO read path, and constrains...
qcow2: Remove unnecessary flush after L2 write
When a new cluster was allocated, we only need a flush after the write to theL2 table if it was a COW and we need to decrease the refcounts of the oldclusters.
qcow2: Use bdrv_(p)write_sync for metadata writes
Use bdrv_(p)write_sync to ensure metadata integrity in case of a crash.
qcow2: Restore L1 entry on l2_allocate failure
If writing the L1 table to disk failed, we need to restore its old content inmemory to avoid inconsistencies.
Reported-by: Juan Quintela <quintela@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
qcow2: Change l2_load to return 0/-errno
Provide the error code to the caller instead of just indicating success/error.
qcow2: Allow qcow2_get_cluster_offset to return errors
qcow2_get_cluster_offset() looks up a given virtual disk offset and returns theoffset of the corresponding cluster in the image file. Errors (e.g. L2 tablecan't be read) are currenctly indicated by a return value of 0, which is...
qcow2: Clear L2 table cache after write error
If the L2 table was already updated in cache, but writing it to disk hasfailed, we must not continue using the changed version in the cache to stayconsistent with what's on the disk.
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 hassuccessfully been initialized.
Also reset the L2 cache in failure case, it's very likely wrong....
block: Open the underlying image file in generic code
Format drivers shouldn't need to bother with things like file names, but ratherjust get an open BlockDriverState for the underlying protocol. This patchintroduces this behaviour for bdrv_open implementation. For protocols which...
qcow2: Trigger blkdebug events
This adds blkdebug events to qcow2 to allow injecting I/O errors in specificplaces.
qcow2: Return 0/-errno in write_l2_entries
Change write_l2_entries to return the real error code instead of -1.
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 inall other error cases.
qcow2: Return 0/-errno in write_l1_entry
Change write_l1_entry to return the real error code instead of -1.
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.
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 ofrequests that are in flight. If we don't do it, the next time the same AIOCB isused for a cluster allocation it will create a loop in the list and qemu will...
qcow2: Fix access after end of array
If a write requests crosses a L2 table boundary and all clusters until theend of the L2 table are usable for the request, we must not look at the nextL2 entry because we already have arrived at the end of the array....
qcow2: Fix signedness bugs
Checking for return codes < 0 isn't really going to work with unsignedtypes. Use signed types instead.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
qcow2: Fix error handling in qcow2_grow_l1_table
Return the appropriate error value instead of always using EIO. Don't free theL1 table on errors, we still need it.
qcow2: Return 0/-errno in get_cluster_table
Switching to 0/-errno allows it to distinguish different error cases.
qcow2: Return 0/-errno in qcow2_alloc_cluster_offset
Returning 0/-errno allows it to distingush different errors classes. Thecluster offset of newly allocated clusters is now returned in the QCowL2Metastruct.
qcow2: Don't ignore qcow2_alloc_clusters return value
Now that qcow2_alloc_clusters can return error codes, we must handle them inthe callers of qcow2_alloc_clusters.
qcow2: Allow qcow2 disk images with size zero
Images with disk size 0 may be used forVM snapshots, but not to save normal block data.
It is possible to create such images usingqemu-img, but opening them later fails.
So even "qemu-img info image.qcow2" is not...
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.
qcow2: Bring synchronous read/write back to life
When the synchronous read and write functions were dropped, they were replacedby generic emulation functions. Unfortunately, these emulation functions don'tprovide the same semantics as the original functions did....
qcow2: Increase maximum cluster size to 2 MB
This patch increases the maximum qcow2 cluster size to 2 MB. Starting with 128kclusters, L2 tables span 2 GB or more of virtual disk space, causing 32 bittruncation and wraparound of signed integers. Therefore some variables need to...
Fix sys-queue.h conflict for good
Problem: Our file sys-queue.h is a copy of the BSD file, but there aresome additions and it's not entirely compatible. Because of that, there havebeen conflicts with system headers on BSD systems. Some hacks have beenintroduced in the commits 15cc9235840a22c289edbe064a9b3c19c5f49896,...
qcow2: Order concurrent AIO requests on the same unallocated cluster
When two AIO requests write to the same cluster, and this cluster isunallocated, currently both requests allocate a new cluster and the second onemerges the first one when it is completed. This means an cluster allocation, a...
qcow2: Fix L1 table memory allocation
Contrary to what one could expect, the size of L1 tables is not clusteraligned. 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...
qcow2: Split out guest cluster functions
qcow2-cluster.c contains all functions related to the management of guestclusters, i.e. what the guest sees on its virtual disk. This code is aboutmapping these guest clusters to host clusters in the image file using the...
qcow2: Rename global functions
The qcow2 source is now split into several more manageable files. During theconversion quite some functions that were static before needed to be changed tobe global to make the source compile again.
We were lucky enough not to get name conflicts with these additional global...
l2_allocate: Write complete sectors
When modifying the L1 table, l2_allocate() needs to write complete sectorsinstead of single entries. The L1 table is already in memory, reading it fromdisk in the block layer to align the request is wasted performance....
alloc_cluster_link_l2: Write complete sectors
When updating the L2 tables in alloc_cluster_link_l2(), write completesectors instead of updating single entries.