summaryrefslogtreecommitdiff
path: root/block/qed.c
AgeCommit message (Collapse)AuthorFilesLines
2011-10-05qed: fix use-after-free during l2 cache commitStefan Hajnoczi1-2/+2
QED's metadata caching strategy allows two parallel requests to race for metadata lookup. The first one to complete will populate the metadata cache and the second one will drop the data it just read in favor of the cached data. There is a use-after-free in qed_read_l2_table_cb() and qed_commit_l2_update() where l2_table->offset was used after the l2_table may have been freed due to a metadata lookup race. Fix this by keeping the l2_offset in a local variable and not reaching into the possibly freed l2_table. Reported-by: Amit Shah <amit.shah@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-20Use glib memory allocation and free functionsAnthony Liguori1-4/+4
qemu_malloc/qemu_free no longer exist after this commit. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-02async: Remove AsyncContextKevin Wolf1-4/+0
The purpose of AsyncContexts was to protect qcow and qcow2 against reentrancy during an emulated bdrv_read/write (which includes a qemu_aio_wait() call and can run AIO callbacks of different requests if it weren't for AsyncContexts). Now both qcow and qcow2 are protected by CoMutexes and AsyncContexts can be removed. Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-06-08qemu-img create: Fix displayed default cluster sizeKevin Wolf1-1/+2
When not specifying a cluster size on the command line, qemu-img printed a cluster size of 0: Formatting '/tmp/test.qcow2', fmt=qcow2 size=67108864 encryption=off cluster_size=0 This patch adds the default cluster size to the QEMUOptionParameter list, so that it displays the default value that is used. Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-05-18qed: support for growing imagesStefan Hajnoczi1-1/+21
The .bdrv_truncate() operation resizes images and growing is easy to implement in QED. Simply check that the new size is valid and then update the image_size header field to reflect the new size. Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-05-18qed: Periodically flush and clear need check bitStefan Hajnoczi1-2/+102
One strategy to limit the startup delay of consistency check when opening image files is to ensure that the file is marked dirty for as little time as possible. QED currently marks the image dirty when the first allocating write request is issued and clears the dirty bit again when the image is cleanly closed. In practice that means the image is marked dirty for most of a guest's lifetime and prone to being in a dirty state upon crash or power failure. It is safe to clear the dirty bit after all allocating write requests have completed and a flush has been performed. This patch adds a timer after the last allocating write request completes. When the timer fires it will flush and then clear the dirty bit. The timer is set to 5 seconds and is cancelled upon arrival of a new allocating write request. Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-04-13qed: Add support for zero clustersAnthony Liguori1-5/+16
Zero clusters are similar to unallocated clusters except instead of reading their value from a backing file when one is available, the cluster is always read as zero. This implements read support only. At this stage, QED will never write a zero cluster. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-02-10qed: Report error for unsupported featuresKevin Wolf1-1/+8
Instead of just returning -ENOTSUP, generate a more detailed error. Unfortunately we don't have a helpful text for features that we don't know yet, so just print the feature mask. It might be useful at least if someone asks for help. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Anthony Liguori <aliguori@us.ibm.com> Acked-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
2011-01-31qed: Images with backing file do not require QED_F_NEED_CHECKStefan Hajnoczi1-7/+17
The consistency check on open is necessary in order to fix inconsistent table offsets left as a result of a crash mid-operation. Images with a backing file actually flush before updating table offsets and are therefore guaranteed to be consistent. Do not mark these images dirty. Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-01-24qed: Refuse to create images on block devicesStefan Hajnoczi1-0/+6
QED relies on the underlying filesystem to extend the file and maintain its size. Check that images are not created on a block device. Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2010-12-17qed: Consistency check supportStefan Hajnoczi1-3/+122
This patch adds support for the qemu-img check command. It also introduces a dirty bit in the qed header to mark modified images as needing a check. This bit is cleared when the image file is closed cleanly. If an image file is opened and it has the dirty bit set, a consistency check will run and try to fix corrupted table offsets. These corruptions may occur if there is power loss while an allocating write is performed. Once the image is fixed it opens as normal again. Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2010-12-17qed: Read/write supportStefan Hajnoczi1-2/+626
This patch implements the read/write state machine. Operations are fully asynchronous and multiple operations may be active at any time. Allocating writes lock tables to ensure metadata updates do not interfere with each other. If two allocating writes need to update the same L2 table they will run sequentially. If two allocating writes need to update different L2 tables they will run in parallel. Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2010-12-17qed: Table, L2 cache, and cluster functionsStefan Hajnoczi1-1/+53
This patch adds code to look up data cluster offsets in the image via the L1/L2 tables. The L2 tables are writethrough cached in memory for performance (each read/write requires a lookup so it is essential to cache the tables). With cluster lookup code in place it is possible to implement bdrv_is_allocated() to query the number of contiguous allocated/unallocated clusters. Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2010-12-17qed: Add QEMU Enhanced Disk image formatStefan Hajnoczi1-0/+554
This patch introduces the qed on-disk layout and implements image creation. Later patches add read/write and other functionality. Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>