qed: Add QEMU Enhanced Disk format
Subsystems (2)
PATCH v6 1/5 docs: Add QED image format specification
In reply to Stefan Hajnoczi--- docs/specs/qed_spec.txt | 130 +++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 130 insertions(+), 0 deletions(-) create mode 100644 docs/specs/qed_spec.txt
docs/specs/qed_spec.txt new file +130 -0
@@ -0,0 +1,130 @@ +=Specification= + +The file format looks like this: + + +----------+----------+----------+-----+ + | cluster0 | cluster1 | cluster2 | ... | + +----------+----------+----------+-----+ + +The first cluster begins with the '''header'''. The header contains information about where regular clusters start; this allows the header to be extensible and store extra information about the image file. A regular cluster may be a '''data cluster''', an '''L2''', or an '''L1 table'''. L1 and L2 tables are composed of one or more contiguous clusters. + +Normally the file size will be a multiple of the cluster size. If the file size is not a multiple, extra information after the last cluster may not be preserved if data is written. Legitimate extra information should use space between the header and the first regular cluster. + +All fields are little-endian. + +==Header== + Header { + uint32_t magic; /* QED\0 */ + + uint32_t cluster_size; /* in bytes */ + uint32_t table_size; /* for L1 and L2 tables, in clusters */ + uint32_t header_size; /* in clusters */ + + uint64_t features; /* format feature bits */ + uint64_t compat_features; /* compat feature bits */ + uint64_t autoclear_features; /* self-resetting feature bits */ + + uint64_t l1_table_offset; /* in bytes */ + uint64_t image_size; /* total logical image size, in bytes */ + + /* if (features & QED_F_BACKING_FILE) */ + uint32_t backing_filename_offset; /* in bytes from start of header */ + uint32_t backing_filename_size; /* in bytes */ + } + +Field descriptions: +* ''cluster_size'' must be a power of 2 in range [2^12, 2^26]. +* ''table_size'' must be a power of 2 in range [1, 16]. +* ''header_size'' is the number of clusters used by the header and any additional information stored before regular clusters. +* ''features'', ''compat_features'', and ''autoclear_features'' are file format extension bitmaps. They work as follows: +** An image with unknown ''features'' bits enabled must not be opened. File format changes that are not backwards-compatible must use ''features'' bits. +** An image with unknown ''compat_features'' bits enabled can be opened safely. The unknown features are simply ignored and represent backwards-compatible changes to the file format. +** An image with unknown ''autoclear_features'' bits enable can be opened safely after clearing the unknown bits. This allows for backwards-compatible changes to the file format which degrade gracefully and can be re-enabled again by a new program later. +* ''l1_table_offset'' is the offset of the first byte of the L1 table in the image file and must be a multiple of ''cluster_size''. +* ''image_size'' is the block device size seen by the guest and must be a multiple of 512 bytes. +* ''backing_filename_offset'' and ''backing_filename_size'' describe a string in (byte offset, byte size) form. It is not NUL-terminated and has no alignment constraints. The string must be stored within the first ''header_size'' clusters. The backing filename may be an absolute path or relative to the image file. + +Feature bits: +* QED_F_BACKING_FILE = 0x01. The image uses a backing file. +* QED_F_NEED_CHECK = 0x02. The image needs a consistency check before use. +* QED_F_BACKING_FORMAT_NO_PROBE = 0x04. The backing file is a raw disk image and no file format autodetection should be attempted. This should be used to ensure that raw backing files are never detected as an image format if they happen to contain magic constants. + +There are currently no defined ''compat_features'' or ''autoclear_features'' bits. + +Fields predicated on a feature bit are only used when that feature is set. The fields always take up header space, regardless of whether or not the feature bit is set. + +==Tables== + +Tables provide the translation from logical offsets in the block device to cluster offsets in the file. + + #define TABLE_NOFFSETS (table_size * cluster_size / sizeof(uint64_t)) + + Table { + uint64_t offsets[TABLE_NOFFSETS]; + } + +The tables are organized as follows: + + +----------+ + | L1 table | + +----------+ + ,------' | '------. + +----------+ | +----------+ + | L2 table | ... | L2 table | + +----------+ +----------+ + ,------' | '------. + +----------+ | +----------+ + | Data | ... | Data | + +----------+ +----------+ + +A table is made up of one or more contiguous clusters. The table_size header field determines table size for an image file. For example, cluster_size=64 KB and table_size=4 results in 256 KB tables. + +The logical image size must be less than or equal to the maximum possible size of clusters rooted by the L1 table: + header.image_size <= TABLE_NOFFSETS * TABLE_NOFFSETS * header.cluster_size + +L1, L2, and data cluster offsets must be aligned to header.cluster_size. The following offsets have special meanings: + +===L2 table offsets=== +* 0 - unallocated. The L2 table is not yet allocated. + +===Data cluster offsets=== +* 0 - unallocated. The data cluster is not yet allocated. + +Future format extensions may wish to store per-offset information. The least significant 12 bits of an offset are reserved for this purpose and must be set to zero. Image files with cluster_size > 2^12 will have more unused bits which should also be zeroed. + +===Unallocated L2 tables and data clusters=== +Reads to an unallocated area of the image file access the backing file. If there is no backing file, then zeroes are produced. The backing file may be smaller than the image file and reads of unallocated areas beyond the end of the backing file produce zeroes. + +Writes to an unallocated area cause a new data clusters to be allocated, and a new L2 table if that is also unallocated. The new data cluster is populated with data from the backing file (or zeroes if no backing file) and the data being written. + +===Logical offset translation=== +Logical offsets are translated into cluster offsets as follows: + + table_bits table_bits cluster_bits + <--------> <--------> <---------------> + +----------+----------+-----------------+ + | L1 index | L2 index | byte offset | + +----------+----------+-----------------+ + + Structure of a logical offset + + offset_mask = ~(cluster_size - 1) # mask for the image file byte offset + + def logical_to_cluster_offset(l1_index, l2_index, byte_offset): + l2_offset = l1_table[l1_index] + l2_table = load_table(l2_offset) + cluster_offset = l2_table[l2_index] & offset_mask + return cluster_offset + byte_offset + +==Consistency checking== + +This section is informational and included to provide background on the use of the QED_F_NEED_CHECK ''features'' bit. + +The QED_F_NEED_CHECK bit is used to mark an image as dirty before starting an operation that could leave the image in an inconsistent state if interrupted by a crash or power failure. A dirty image must be checked on open because its metadata may not be consistent. + +Consistency check includes the following invariants: +# Each cluster is referenced once and only once. It is an inconsistency to have a cluster referenced more than once by L1 or L2 tables. A cluster has been leaked if it has no references. +# Offsets must be within the image file size and must be ''cluster_size'' aligned. +# Table offsets must at least ''table_size'' * ''cluster_size'' bytes from the end of the image file so that there is space for the entire table. + +The consistency check process starts by from ''l1_table_offset'' and scans all L2 tables. After the check completes with no other errors besides leaks, the QED_F_NEED_CHECK bit can be cleared and the image can be accessed.
Signature · 1 line
1.7.2.3
PATCH v6 5/5 qed: Consistency check support
In reply to Stefan HajnocziThis 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.
--- block/qed-check.c | 210 +++++++++++++++++++++++++++++++++++++++++++++++++++++ block/qed.c | 125 +++++++++++++++++++++++++++++++- block/qed.h | 4 + 3 files changed, 336 insertions(+), 3 deletions(-) create mode 100644 block/qed-check.c
block/qed-check.c new file +210 -0
@@ -0,0 +1,210 @@ +/* +* QEMU Enhanced Disk Format Consistency Check +* +* Copyright IBM, Corp. 2010 +* +* Authors: +* Stefan Hajnoczi <[email protected]> +* +* This work is licensed under the terms of the GNU LGPL, version 2 or later. +* See the COPYING.LIB file in the top-level directory. +* +*/ + +#include "qed.h" + +typedef struct { +BDRVQEDState *s; +BdrvCheckResult *result; +bool fix;/* whether to fix invalid offsets */ + +size_t nclusters; +uint32_t *used_clusters;/* referenced cluster bitmap */ + +QEDRequest request; +}QEDCheck ; + +static bool qed_test_bit (uint32_t *bitmap,uint64_t n) { +return !!(bitmap[n /32 ] & (1 << (n %32 ))); +} + +static void qed_set_bit (uint32_t *bitmap,uint64_t n) { + bitmap[n /32 ] |=1 << (n %32 ); +} + +/** +* Set bitmap bits for clusters +* +* @check: Check structure +* @offset: Starting offset in bytes +* @n: Number of clusters +*/ +static bool qed_set_used_clusters (QEDCheck *check,uint64_t offset, +unsigned int n) +{ +uint64_t cluster =qed_bytes_to_clusters (check->s, offset); +unsigned int corruptions =0 ; + +while (n-- !=0 ) { +/* Clusters should only be referenced once */ +if (qed_test_bit (check->used_clusters, cluster)) { + corruptions++; + } + +qed_set_bit (check->used_clusters, cluster); + cluster++; + } + + check->result->corruptions += corruptions; +return corruptions ==0 ; +} + +/** +* Check an L2 table +* +* @ret: Number of invalid cluster offsets +*/ +static unsigned int qed_check_l2_table (QEDCheck *check,QEDTable *table) +{ +BDRVQEDState *s = check->s; +unsigned int i, num_invalid =0 ; + +for (i =0 ; i < s->table_nelems; i++) { +uint64_t offset = table->offsets[i]; + +if (!offset) { +continue ; + } + +/* Detect invalid cluster offset */ +if (!qed_check_cluster_offset (s, offset)) { +if (check->fix) { + table->offsets[i] =0 ; + }else { + check->result->corruptions++; + } + + num_invalid++; +continue ; + } + +qed_set_used_clusters (check, offset,1 ); + } + +return num_invalid; +} + +/** +* Descend tables and check each cluster is referenced once only +*/ +static int qed_check_l1_table (QEDCheck *check,QEDTable *table) +{ +BDRVQEDState *s = check->s; +unsigned int i, num_invalid_l1 =0 ; +int ret, last_error =0 ; + +/* Mark L1 table clusters used */ +qed_set_used_clusters (check, s->header.l1_table_offset, + s->header.table_size); + +for (i =0 ; i < s->table_nelems; i++) { +unsigned int num_invalid_l2; +uint64_t offset = table->offsets[i]; + +if (!offset) { +continue ; + } + +/* Detect invalid L2 offset */ +if (!qed_check_table_offset (s, offset)) { +/* Clear invalid offset */ +if (check->fix) { + table->offsets[i] =0 ; + }else { + check->result->corruptions++; + } + + num_invalid_l1++; +continue ; + } + +if (!qed_set_used_clusters (check, offset, s->header.table_size)) { +continue ;/* skip an invalid table */ + } + + ret =qed_read_l2_table_sync (s, &check->request, offset); +if (ret) { + check->result->check_errors++; + last_error = ret; +continue ; + } + + num_invalid_l2 =qed_check_l2_table (check, + check->request.l2_table->table); + +/* Write out fixed L2 table */ +if (num_invalid_l2 >0 && check->fix) { + ret =qed_write_l2_table_sync (s, &check->request,0 , + s->table_nelems, false); +if (ret) { + check->result->check_errors++; + last_error = ret; +continue ; + } + } + } + +/* Drop reference to final table */ +qed_unref_l2_cache_entry (check->request.l2_table); + check->request.l2_table =NULL ; + +/* Write out fixed L1 table */ +if (num_invalid_l1 >0 && check->fix) { + ret =qed_write_l1_table_sync (s,0 , s->table_nelems); +if (ret) { + check->result->check_errors++; + last_error = ret; + } + } + +return last_error; +} + +/** +* Check for unreferenced (leaked) clusters +*/ +static void qed_check_for_leaks (QEDCheck *check) +{ +BDRVQEDState *s = check->s; +size_t i; + +for (i = s->header.header_size; i < check->nclusters; i++) { +if (!qed_test_bit (check->used_clusters, i)) { + check->result->leaks++; + } + } +} + +int qed_check (BDRVQEDState *s,BdrvCheckResult *result,bool fix) +{ +QEDCheck check = { + .s = s, + .result = result, + .nclusters =qed_bytes_to_clusters (s, s->file_size), + .request = { .l2_table =NULL }, + .fix = fix, + }; +int ret; + + check.used_clusters =qemu_mallocz (((check.nclusters +31 ) /32 ) * +sizeof (check.used_clusters[0 ])); + + ret =qed_check_l1_table (&check, s->l1_table); +if (ret ==0 ) { +/* Only check for leaks if entire image was scanned successfully */ +qed_check_for_leaks (&check); + } + +qemu_free (check.used_clusters); +return ret; +}
block/qed.c +122 -3
155 lines not on this page · raw message
block/qed.h +4 -0
@@ -50,11 +50,15 @@ enum {/* The image supports a backing file */ QED_F_BACKING_FILE =0x01 , +/* The image needs a consistency check before use */ +QED_F_NEED_CHECK =0x02 , +/* The backing file format must not be probed, treat as raw image */ QED_F_BACKING_FORMAT_NO_PROBE =0x04 ,/* Feature bits must be used when the on-disk format changes */ QED_FEATURE_MASK =QED_F_BACKING_FILE |/* supported feature bits */ +QED_F_NEED_CHECK |QED_F_BACKING_FORMAT_NO_PROBE ,QED_COMPAT_FEATURE_MASK =0 ,/* supported compat feature bits */ QED_AUTOCLEAR_FEATURE_MASK = 0, /* supported autoclear feature bits */
Signature · 1 line
1.7.2.3
v6 cover qed: Add QEMU Enhanced Disk format
For a changelog against v5, see below.
QEMU Enhanced Disk format is a disk image format that forgoes features found in qcow2 in favor of better levels of performance and data integrity. Due to its simpler on-disk layout, it is possible to safely perform metadata updates more efficiently.
Installations, suspend-to-disk, and other allocation-heavy I/O workloads will see increased performance due to fewer I/Os and syncs. Workloads that do not cause new clusters to be allocated will perform similar to raw images due to in-memory metadata caching.
The format supports sparse disk images. It does not rely on the host filesystem holes feature, making it a good choice for sparse disk images that need to be transferred over channels where holes are not supported.
Backing files are supported so only deltas against a base image can be stored. The base image may be smaller than the image file.
The file format is extensible so that additional features can be added later with graceful compatibility handling. A specification for the file format is included in this patchset.
Internal snapshots are not supported. This eliminates the need for additional metadata to track copy-on-write clusters.
Compression and encryption are not supported. They add complexity and can be implemented at other layers in the stack (i.e. inside the guest or on the host). Encryption has been identified as a potential future extension and the file format allows for this.
---
The code is available from git:
http://repo.or.cz/w/qemu/stefanha.git/shortlog/refs/heads/qed-v6
I have preserved distinct commits against v5 for easier reviewing here:
http://repo.or.cz/w/qemu/stefanha.git/shortlog/refs/heads/qed-v6-presquash
v6:
* Calculate correct offset before tracing
* Fix >80 character lines
* Replace qed_acb_build_qiov() with qemu_iovec_copy()
* Remove table locking mechanism (v2) and use allocating write queue again
* Trace qed_write_table_cb() flush state
v5:
* Describe reserved offset bits in QED format spec
* Backing filename must be stored within header clusters
* Backing file clarifications in QED format spec
* List autoclear_features in QED header struct in QED format spec
* Return -EINVAL when header magic check fails
* Allow bdrv_flush() to return errors
v4:
* Use bdrv_*() instead of POSIX APIs to create an image file
* Lift the non-zero image size restriction
* Fix qed.c/qed.h style comments from Kevin
v3:
* Flush before L2 update when a backing file is used
* Use QED_F_BACKING_FORMAT_NO_PROBE instead of backing_fmt header field
* Allow non-cluster sized images
* Implement autoclear feature bits
* Implement backing image smaller size - reads from backing image should zero beyond EOF
* Preserve errno in qed_find_cluster_cb() - don't dumb down to QED_CLUSTER_ERROR
* Use ffs() instead of get_bits_from_size()
* Remove l2_cache argument to qed_unref_l2_cache_entry
* Eliminate L2TableAllocFunc function pointer
* Split qed_aio_write in-place and allocating code path to make code clearer
* Document how L2 cache is used
* Document qed_find_cluster()
* Update QED specification
* Fix COPYING.LIB LGPL license file references
* Add copyright header to qed-check.c
* Avoid the bytes_to_str()/cvtstr()/sztostr() dependency until Jes' strtosz() goes in
v2:
* Add QED format specification to documentation
* Use __builtin_ctzl() for get_bits_from_size()
* Fine-grained table locking to allow concurrent allocating write requests
* Fix qemu_free() instead of qemu_vfree() in qed_unref_l2_cache_entry()
* Comment clean-ups
Makefile.objs | 2 + block/qed-check.c | 210 ++++++++ block/qed-cluster.c | 154 ++++++ block/qed-gencb.c | 32 ++ block/qed-l2-cache.c | 173 ++++++ block/qed-table.c | 319 +++++++++++ block/qed.c | 1349 +++++++++++++++++++++++++++++++++++++++++++++++ block/qed.h | 301 +++++++++++ block_int.h | 1 + docs/specs/qed_spec.txt | 130 +++++ trace-events | 21 + 11 files changed, 2692 insertions(+), 0 deletions(-)
PATCH v6 4/5 qed: Read/write support
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.
--- Makefile.objs | 1 + block/qed.c | 628 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++- block/qed.h | 26 +++ trace-events | 10 + 4 files changed, 663 insertions(+), 2 deletions(-)
Makefile.objs +1 -0
@@ -21,6 +21,7 @@ block-obj-$(CONFIG_LINUX_AIO) += linux-aio.o block-nested-y += raw.o cow.o qcow.o vdi.o vmdk.o cloop.o dmg.o bochs.o vpc.o vvfat.o block-nested-y += qcow2.o qcow2-refcount.o qcow2-cluster.o qcow2-snapshot.o block-nested-y += qed.o qed-gencb.o qed-l2-cache.o qed-table.o qed-cluster.o +block-nested-y += qed-check.o block-nested-y += parallels.o nbd.o blkdebug.o sheepdog.o blkverify.o block-nested-$(CONFIG_WIN32) += raw-win32.o block-nested-$(CONFIG_POSIX) += raw-posix.o
block/qed.c +626 -2
672 lines not on this page · raw message
block/qed.h +26 -0
@@ -116,6 +116,29 @@ typedef struct QEDRequest {CachedL2Table *l2_table; } QEDRequest; +typedef struct QEDAIOCB { +BlockDriverAIOCB common; +QEMUBH *bh; +int bh_ret;/* final return status for completion bh */ +QSIMPLEQ_ENTRY (QEDAIOCB) next;/* next request */ +bool is_write;/* false - read, true - write */ +bool *finished;/* signal for cancel completion */ +uint64_t end_pos;/* request end on block device, in bytes */ + +/* User scatter-gather list */ +QEMUIOVector *qiov; +size_t qiov_offset;/* byte count already processed */ + +/* Current cluster scatter-gather list */ +QEMUIOVector cur_qiov; +uint64_t cur_pos;/* position on block device, in bytes */ +uint64_t cur_cluster;/* cluster offset in image file */ +unsigned int cur_nclusters;/* number of clusters being accessed */ +int find_cluster_ret;/* used for L1/L2 update */ + +QEDRequest request; +}QEDAIOCB ; + typedef struct { BlockDriverState *bs; /* device */ uint64_t file_size; /* length of image file, in bytes */
@@ -127,6 +150,9 @@ typedef struct {uint32_t l1_shift;uint32_t l2_shift;uint32_t l2_mask; + +/* Allocating write request queue */ + QSIMPLEQ_HEAD(, QEDAIOCB) allocating_write_reqs; } BDRVQEDState;enum {
trace-events +10 -0
@@ -203,3 +203,13 @@ disable qed_read_table(void *s, uint64_t offset, void *table) "s %p offset %"PRI disable qed_read_table_cb(void *s, void *table, int ret) "s %p table %p ret %d" disable qed_write_table(void *s, uint64_t offset, void *table, unsigned int index, unsigned int n) "s %p offset %"PRIu64" table %p index %u n %u" disable qed_write_table_cb(void *s, void *table, int flush, int ret) "s %p table %p flush %d ret %d" + +# block/qed.c +disable qed_aio_complete(void *s, void *acb, int ret) "s %p acb %p ret %d" +disable qed_aio_setup(void *s, void *acb, int64_t sector_num, int nb_sectors, void *opaque, int is_write) "s %p acb %p sector_num %"PRId64" nb_sectors %d opaque %p is_write %d" +disable qed_aio_next_io(void *s, void *acb, int ret, uint64_t cur_pos) "s %p acb %p ret %d cur_pos %"PRIu64"" +disable qed_aio_read_data(void *s, void *acb, int ret, uint64_t offset, size_t len) "s %p acb %p ret %d offset %"PRIu64" len %zu" +disable qed_aio_write_data(void *s, void *acb, int ret, uint64_t offset, size_t len) "s %p acb %p ret %d offset %"PRIu64" len %zu" +disable qed_aio_write_prefill(void *s, void *acb, uint64_t start, size_t len, uint64_t offset) "s %p acb %p start %"PRIu64" len %zu offset %"PRIu64"" +disable qed_aio_write_postfill(void *s, void *acb, uint64_t start, size_t len, uint64_t offset) "s %p acb %p start %"PRIu64" len %zu offset %"PRIu64"" +disable qed_aio_write_main(void *s, void *acb, int ret, uint64_t offset, size_t len) "s %p acb %p ret %d offset %"PRIu64" len %zu"
Signature · 1 line
1.7.2.3
PATCH v6 2/5 qed: Add QEMU Enhanced Disk image format
In reply to Stefan HajnocziThis patch introduces the qed on-disk layout and implements image creation. Later patches add read/write and other functionality.
--- Makefile.objs | 1 + block/qed.c | 554 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ block/qed.h | 148 +++++++++++++++ block_int.h | 1 + 4 files changed, 704 insertions(+), 0 deletions(-) create mode 100644 block/qed.c create mode 100644 block/qed.h
Makefile.objs +1 -0
@@ -20,6 +20,7 @@ block-obj-$(CONFIG_LINUX_AIO) += linux-aio.o block-nested-y += raw.o cow.o qcow.o vdi.o vmdk.o cloop.o dmg.o bochs.o vpc.o vvfat.o block-nested-y += qcow2.o qcow2-refcount.o qcow2-cluster.o qcow2-snapshot.o +block-nested-y += qed.o block-nested-y += parallels.o nbd.o blkdebug.o sheepdog.o blkverify.o block-nested-$(CONFIG_WIN32) += raw-win32.o block-nested-$(CONFIG_POSIX) += raw-posix.o
block/qed.c new file +554 -0
554 lines not on this page · raw message
block/qed.h new file +148 -0
148 lines not on this page · raw message
block_int.h +1 -0
@@ -38,6 +38,7 @@#define BLOCK_OPT_BACKING_FILE "backing_file"#define BLOCK_OPT_BACKING_FMT "backing_fmt"#define BLOCK_OPT_CLUSTER_SIZE "cluster_size" +#define BLOCK_OPT_TABLE_SIZE "table_size"#define BLOCK_OPT_PREALLOC "preallocation" typedef struct AIOPool {
Signature · 1 line
1.7.2.3
PATCH v6 3/5 qed: Table, L2 cache, and cluster functions
In reply to Stefan HajnocziThis 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.
--- Makefile.objs | 2 +- block/qed-cluster.c | 154 ++++++++++++++++++++++++ block/qed-gencb.c | 32 +++++ block/qed-l2-cache.c | 173 +++++++++++++++++++++++++++ block/qed-table.c | 319 ++++++++++++++++++++++++++++++++++++++++++++++++++ block/qed.c | 54 +++++++++- block/qed.h | 123 +++++++++++++++++++ trace-events | 11 ++ 8 files changed, 866 insertions(+), 2 deletions(-) create mode 100644 block/qed-cluster.c create mode 100644 block/qed-gencb.c create mode 100644 block/qed-l2-cache.c create mode 100644 block/qed-table.c
Makefile.objs +1 -1
@@ -20,7 +20,7 @@ block-obj-$(CONFIG_LINUX_AIO) += linux-aio.o block-nested-y += raw.o cow.o qcow.o vdi.o vmdk.o cloop.o dmg.o bochs.o vpc.o vvfat.o block-nested-y += qcow2.o qcow2-refcount.o qcow2-cluster.o qcow2-snapshot.o -block-nested-y += qed.o +block-nested-y += qed.o qed-gencb.o qed-l2-cache.o qed-table.o qed-cluster.o block-nested-y += parallels.o nbd.o blkdebug.o sheepdog.o blkverify.o block-nested-$(CONFIG_WIN32) += raw-win32.o block-nested-$(CONFIG_POSIX) += raw-posix.o
block/qed-cluster.c new file +154 -0
154 lines not on this page · raw message
block/qed-gencb.c new file +32 -0
@@ -0,0 +1,32 @@ +/* +* QEMU Enhanced Disk Format +* +* Copyright IBM, Corp. 2010 +* +* Authors: +* Stefan Hajnoczi <[email protected]> +* +* This work is licensed under the terms of the GNU LGPL, version 2 or later. +* See the COPYING.LIB file in the top-level directory. +* +*/ + +#include "qed.h" + +void *gencb_alloc (size_t len,BlockDriverCompletionFunc *cb,void *opaque) +{ +GenericCB *gencb =qemu_malloc (len); + gencb->cb = cb; + gencb->opaque = opaque; +return gencb; +} + +void gencb_complete (void *opaque,int ret) +{ +GenericCB *gencb = opaque; +BlockDriverCompletionFunc *cb = gencb->cb; +void *user_opaque = gencb->opaque; + +qemu_free (gencb); +cb (user_opaque, ret); +}
block/qed-l2-cache.c new file +173 -0
173 lines not on this page · raw message
block/qed-table.c new file +319 -0
319 lines not on this page · raw message
block/qed.c +53 -1
80 lines not on this page · raw message
block/qed.h +123 -0
145 lines not on this page · raw message
trace-events +11 -0
@@ -192,3 +192,14 @@ disable sun4m_iommu_bad_addr(uint64_t addr) "bad addr %"PRIx64"" # vl.c disable vm_state_notify(int running, int reason) "running %d reason %d" + +# block/qed-l2-cache.c +disable qed_alloc_l2_cache_entry(void *l2_cache, void *entry) "l2_cache %p entry %p" +disable qed_unref_l2_cache_entry(void *entry, int ref) "entry %p ref %d" +disable qed_find_l2_cache_entry(void *l2_cache, void *entry, uint64_t offset, int ref) "l2_cache %p entry %p offset %"PRIu64" ref %d" + +# block/qed-table.c +disable qed_read_table(void *s, uint64_t offset, void *table) "s %p offset %"PRIu64" table %p" +disable qed_read_table_cb(void *s, void *table, int ret) "s %p table %p ret %d" +disable qed_write_table(void *s, uint64_t offset, void *table, unsigned int index, unsigned int n) "s %p offset %"PRIu64" table %p index %u n %u" +disable qed_write_table_cb(void *s, void *table, int flush, int ret) "s %p table %p flush %d ret %d"
Signature · 1 line
1.7.2.3
Am 06.12.2010 17:07, schrieb Stefan Hajnoczi:
Quoted 26 lines
For a changelog against v5, see below.
QEMU Enhanced Disk format is a disk image format that forgoes features found in qcow2 in favor of better levels of performance and data integrity. Due to its simpler on-disk layout, it is possible to safely perform metadata updates more efficiently.
Installations, suspend-to-disk, and other allocation-heavy I/O workloads will see increased performance due to fewer I/Os and syncs. Workloads that do not cause new clusters to be allocated will perform similar to raw images due to in-memory metadata caching.
The format supports sparse disk images. It does not rely on the host filesystem holes feature, making it a good choice for sparse disk images that need to be transferred over channels where holes are not supported.
Backing files are supported so only deltas against a base image can be stored. The base image may be smaller than the image file.
The file format is extensible so that additional features can be added later with graceful compatibility handling. A specification for the file format is included in this patchset.
Internal snapshots are not supported. This eliminates the need for additional metadata to track copy-on-write clusters.
Quoted 7 lines
Compression and encryption are not supported. They add complexity and can be implemented at other layers in the stack (i.e. inside the guest or on the host). Encryption has been identified as a potential future extension and the file format allows for this.
Signed-off-by Anthony Liguori <[email protected]>Signed-off-by Stefan Hajnoczi <[email protected]>
Thanks, reluctantly applied to the block branch. ;-)
Kevin
Quoted 32 lines · Kevin Wolf
Am 06.12.2010 17:07, schrieb Stefan Hajnoczi:
Quoted 31 lines
For a changelog against v5, see below.
QEMU Enhanced Disk format is a disk image format that forgoes features found in qcow2 in favor of better levels of performance and data integrity. Due to its simpler on-disk layout, it is possible to safely perform metadata updates more efficiently.
Installations, suspend-to-disk, and other allocation-heavy I/O workloads will see increased performance due to fewer I/Os and syncs. Workloads that do not cause new clusters to be allocated will perform similar to raw images due to in-memory metadata caching.
The format supports sparse disk images. It does not rely on the host filesystem holes feature, making it a good choice for sparse disk images that need to be transferred over channels where holes are not supported.
Backing files are supported so only deltas against a base image can be stored. The base image may be smaller than the image file.
The file format is extensible so that additional features can be added later with graceful compatibility handling. A specification for the file format is included in this patchset.
Internal snapshots are not supported. This eliminates the need for additional metadata to track copy-on-write clusters.
Compression and encryption are not supported. They add complexity and can be implemented at other layers in the stack (i.e. inside the guest or on the host). Encryption has been identified as a potential future extension and the file format allows for this.
Quoted 4 lines
Quoted 2 lines
Signed-off-by Anthony Liguori <[email protected]>Signed-off-by Stefan Hajnoczi <[email protected]>Thanks, reluctantly applied to the block branch. ;-)
Thank you Kevin!
Stefan