summaryrefslogtreecommitdiffstats
path: root/block/qcow2.c
Commit message (Collapse)AuthorAgeFilesLines
* Revert "qcow2: Bring synchronous read/write back to life"Kevin Wolf2009-10-271-49/+2
| | | | | | | | It was merely a workaround and the real fix is done now. This reverts commit ef845c3bf421290153154635dc18eaa677cecb43. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* qcow2: Bring synchronous read/write back to lifeKevin Wolf2009-10-151-2/+49
| | | | | | | | | | | | | | | | | | | | | | 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. The original bdrv_read would mean that we read some data synchronously and that we won't be interrupted during this read. The latter assumption is no longer true with the emulation function which needs to use qemu_aio_poll and therefore allows the callback of any other concurrent AIO request to be run during the read. Which in turn means that (meta)data read earlier could have changed and be invalid now. qcow2 is not prepared to work in this way and it's just scary how many places there are where other requests could run. I'm not sure yet where exactly it breaks, but you'll see breakage with virtio on qcow2 with a backing file. Providing synchronous functions again fixes the problem for me. Patchworks-ID: 35437 Signed-off-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* Fix sys-queue.h conflict for goodBlue Swirl2009-09-121-8/+8
| | | | | | | | | | | | | | | 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, f40d753718c72693c5f520f0d9899f6e50395e94, 96555a96d724016e13190b28cffa3bc929ac60dc and 3990d09adf4463eca200ad964cc55643c33feb50 but the fixes were fragile. Solution: Avoid the conflict entirely by renaming the functions and the file. Revert the previous hacks. Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* qcow2: Order concurrent AIO requests on the same unallocated clusterKevin Wolf2009-09-091-5/+50
| | | | | | | | | | | | | | | | | 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 read and a cluster deallocation which cause some overhead. If we simply let the second request wait until the first one is done, we improve overall performance with AIO requests (specifially, qcow2/virtio combinations). This patch maintains a list of in-flight requests that have allocated new clusters. A second request touching the same cluster is limited so that it either doesn't touch the allocation of the first request (so it can have a non-overlapping allocation) or it waits for the first request to complete. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* qcow2: Fix metadata preallocationKevin Wolf2009-09-091-1/+3
| | | | | | | | | | | | | The wrong version of the preallocation patch has been applied, so this is the remaining diff. We can't use truncate to grow the image file to the right size because we don't know if metadata has been written after the last data cluster. In this case truncate would shrink the file and destroy its metadata. Write a zero sector at the end of the virtual disk instead to ensure that the file is big enough. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* Fix gcc 3 warning about uninitialized variableBlue Swirl2009-08-291-1/+1
| | | | | | If nb_sectors is 0, cluster_offset will not be initialized. Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* qcow2: Metadata preallocationKevin Wolf2009-08-271-2/+79
| | | | | | | | | | | | | | | | | | This introduces a qemu-img create option for qcow2 which allows the metadata to be preallocated, i.e. clusters are reserved in the refcount table and L1/L2 tables, but no data is written to them. Metadata is quite small, so this happens in almost no time. Especially with qcow2 on virtio this helps to gain a bit of performance during the initial writes. However, as soon as create a snapshot, we're back to the normal slow speed, obviously. So this isn't the real fix, but kind of a cheat while we're still having trouble with qcow2 on virtio. Note that the option is disabled by default and needs to be specified explicitly using qemu-img create -f qcow2 -o preallocation=metadata. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* replace bdrv_{get, put}_buffer with bdrv_{load, save}_vmstateChristoph Hellwig2009-07-161-8/+14
| | | | | | | | | | | | The VM state offset is a concept internal to the image format. Replace the old bdrv_{get,put}_buffer method that require an index into the image file that is constructed from the VM state offset and an offset into the vmstate with the bdrv_{load,save}_vmstate that just take an offset into the VM state. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* qcow2: Fix L1 table memory allocationKevin Wolf2009-07-101-1/+2
| | | | | | | | | | 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 write would access memory after the end of the L1 table. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* qcow2: Make cache=writethrough defaultKevin Wolf2009-07-091-8/+0
| | | | | | | | | The performance of qcow2 has improved meanwhile, so we don't need to special-case it any more. Switch the default to write-through caching like all other block drivers. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* Fix QCOW2 debugging code to compile againFilip Navara2009-06-291-5/+1
| | | | | | | Updated to use C99 comments. Signed-off-by: Filip Navara <filip.navara@gmail.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* qcow2: Rename global functionsKevin Wolf2009-06-161-26/+29
| | | | | | | | | | | | | 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 names, but they are not nice. This patch adds a qcow2_ prefix to all of the global functions in qcow2. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* qcow2: Split out snapshot functionsKevin Wolf2009-06-161-392/+0
| | | | | | | qcow2-snapshot.c contains the code related to snapshotting. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* qcow2: Split out guest cluster functionsKevin Wolf2009-06-161-765/+2
| | | | | | | | | | 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 two-level lookup tables. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* qcow2: Split out refcount handlingKevin Wolf2009-06-161-869/+2
| | | | | | | | | | | | qcow2-refcount.c contains all functions which are related to cluster allocation and management in the image file. A large part of this is the reference counting of these clusters. Also a header file qcow2.h is introduced which will contain the interface of the split qcow2 modules. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* qcow2: Change default cluster size to 64kKevin Wolf2009-06-161-1/+1
| | | | | | | | Larger cluster sizes mean less metadata. This has been discussion a few times, let's do it now. This turns 64k clusters on by default for new images. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* qemu-img: Print available options with -o ?Kevin Wolf2009-06-061-5/+25
| | | | | | | This patch adds a small help text to each of the options in the block drivers which can be displayed by using qemu-img create -f fmt -o ? Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* fully split aio_pool from BlockDriverChristoph Hellwig2009-05-271-11/+14
| | | | | | | | | | | | | | Now that we have a separate aio pool structure we can remove those aio pool details from BlockDriver. Every driver supporting AIO now needs to declare a static AIOPool with the aiocb size and the cancellation method. This cleans up the current code considerably and will make it cleaner and more obvious to support two different aio implementations behind a single BlockDriver. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* qcow2: Update multiple refcounts at onceKevin Wolf2009-05-271-4/+36
| | | | | | | | Don't write each single changed refcount block entry to the disk after it is written, but update all entries of the block and write all of them at once. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* qcow2: Refactor update_refcountKevin Wolf2009-05-271-30/+56
| | | | | | | | | | This is a preparation patch with no functional changes. It moves the allocation of new refcounts block to a new function and makes update_cluster_refcount (for one cluster) call update_refcount (for multiple clusters) instead the other way round. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* qcow/qcow2: Drop synchronous qcow_write()Kevin Wolf2009-05-271-41/+1
| | | | | | | | There is only one (internal) user left and it can be switched to the normal emulation provided in block.c Signed-off-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* qcow2: Allow different cluster sizesKevin Wolf2009-05-221-5/+48
| | | | | | | | Add an option to specify the cluster size of a newly created qcow2 image. Default is 4k which is the same value that was hard-coded before. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* Convert all block drivers to new bdrv_createKevin Wolf2009-05-221-5/+31
| | | | | | | | | | | | Now we can make use of the newly introduced option structures. Instead of having bdrv_create carry more and more parameters (which are format specific in most cases), just pass a option structure as defined by the driver itself. bdrv_create2() contains an emulation of the old interface to simplify the transition. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* Do not attempt to allocate sn_tab when there are no snapshotsmalc2009-05-211-0/+5
| | | | | | | This was caught by a7d27b536ffc0773028a90f14580552c0c3ddb2a which aborted on this attempt, thanks to Alex Ivanov for report. Signed-off-by: malc <av1474@comtv.ru>
* Move block drivers into their own directoryAnthony Liguori2009-05-141-0/+2931
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
OpenPOWER on IntegriCloud