Skip to contentSkip to conversation

(no subject)

Qemu-devel Superseded Stefan Hajnoczi 4 participants 11 messages Oct 22, 2010 – Oct 28, 2010

Subsystems (2)

v3 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

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.

---
This code is also available from git:

http://repo.or.cz/w/qemu/stefanha.git/shortlog/refs/heads/qed-v3

I have preserved distinct commits against v2 for easier reviewing here:

http://repo.or.cz/w/qemu/stefanha.git/shortlog/refs/heads/qed-v3-presquash

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

#1 lore raw

PATCH v3 1/5 docs: Add QED image format specification

---
 docs/specs/qed_spec.txt |  128 +++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 128 insertions(+), 0 deletions(-)
 create mode 100644 docs/specs/qed_spec.txt
docs/specs/qed_spec.txt new file +128 -0
new file mode 100644
index 0000000..e4425c8
@@ -0,0 +1,128 @@
+=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 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'' is a string in (byte offset, byte size) form.  It is not NUL-terminated and has no alignment constraints.
+
+Feature bits:
+* QED_F_BACKING_FILE = 0x01.  The image uses a backing file.  The backing filename string is given in the ''backing_filename_{offset,size}'' fields and may be an absolute path or relative to the image 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 images 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
+
+All offsets in L1 and L2 tables are cluster-aligned.  The least significant bits up to ''cluster_size'' are reserved and must be zero.  This may be used in future format extensions to store per-offset information.
+
+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.
+
+===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 image (or zeroes if no backing image) 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.1
#2 lore raw

PATCH v3 2/5 qed: Add QEMU Enhanced Disk image format

In reply to Stefan Hajnoczi

This 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   |  546 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 block/qed.h   |  148 ++++++++++++++++
 3 files changed, 695 insertions(+), 0 deletions(-)
 create mode 100644 block/qed.c
 create mode 100644 block/qed.h
Makefile.objs +1 -0
index 6e6f60a..2f036c8 100644
@@ -14,6 +14,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 +546 -0

546 lines not on this page · raw message

block/qed.h new file +148 -0

148 lines not on this page · raw message

Signature · 1 line
1.7.1
#3 lore raw

PATCH v3 3/5 qed: Table, L2 cache, and cluster functions

In reply to Stefan Hajnoczi

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.

---
 Makefile.objs        |    2 +-
 block/qed-cluster.c  |  154 ++++++++++++++++++++++++
 block/qed-gencb.c    |   32 +++++
 block/qed-l2-cache.c |  173 +++++++++++++++++++++++++++
 block/qed-table.c    |  317 ++++++++++++++++++++++++++++++++++++++++++++++++++
 block/qed.c          |   54 +++++++++-
 block/qed.h          |  118 +++++++++++++++++++
 trace-events         |   11 ++
 8 files changed, 859 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
index 2f036c8..bcab5bc 100644
@@ -14,7 +14,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
new file mode 100644
index 0000000..1513dc6
@@ -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 +317 -0

317 lines not on this page · raw message

block/qed.c +53 -1

80 lines not on this page · raw message

block/qed.h +118 -0

142 lines not on this page · raw message

trace-events +11 -0
index ed2055e..60fc225 100644
@@ -81,3 +81,14 @@ disable apic_mem_writel(uint64_t addr, uint32_t val) "%"PRIx64" = %08x"
 disable apic_reset_irq_delivered(int apic_irq_delivered) "old coalescing %d"
 disable apic_get_irq_delivered(int apic_irq_delivered) "returning coalescing %d"
 disable apic_set_irq(int apic_irq_delivered) "coalescing %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 ret) "s %p table %p ret %d"
Signature · 1 line
1.7.1
#4 lore raw

PATCH v3 4/5 qed: Read/write support

In reply to Stefan Hajnoczi

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-lock.c |  124 ++++++++++
 block/qed.c      |  667 +++++++++++++++++++++++++++++++++++++++++++++++++++++-
 block/qed.h      |   43 ++++
 trace-events     |   10 +
 5 files changed, 843 insertions(+), 2 deletions(-)
 create mode 100644 block/qed-lock.c
Makefile.objs +1 -0
index bcab5bc..8ae17d8 100644
@@ -15,6 +15,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-lock.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-lock.c new file +124 -0

124 lines not on this page · raw message

block/qed.c +665 -2

711 lines not on this page · raw message

block/qed.h +43 -0

61 lines not on this page · raw message

trace-events +10 -0
index 60fc225..fd99730 100644
@@ -92,3 +92,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 ret) "s %p table %p 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.1
#5 lore raw

PATCH v3 5/5 qed: Consistency check support

In reply to Stefan Hajnoczi

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.

---
 Makefile.objs     |    2 +-
 block/qed-check.c |  210 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 block/qed.c       |  125 +++++++++++++++++++++++++++++++-
 block/qed.h       |    9 ++
 4 files changed, 342 insertions(+), 4 deletions(-)
 create mode 100644 block/qed-check.c
Makefile.objs +1 -1
index 8ae17d8..62cab02 100644
@@ -15,7 +15,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-lock.o
+block-nested-y += qed-lock.o 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-check.c new file +210 -0

210 lines not on this page · raw message

block/qed.c +122 -3

155 lines not on this page · raw message

block/qed.h +9 -0
index a356f20..c966f86 100644
@@ -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 */
@@ -245,6 +249,11 @@ void qed_find_cluster(BDRVQEDState *s, QEDRequest *request, uint64_t pos,
                       size_t len, QEDFindClusterFunc *cb, void *opaque);
 
 /**
+ * Consistency check
+ */
+int qed_check(BDRVQEDState *s, BdrvCheckResult *result, bool fix);
+
+/**
  * Utility functions
  */
 QEDTable *qed_alloc_table(BDRVQEDState *s);
Signature · 1 line
1.7.1
#6 lore raw

[Qemu-devel] Re: [PATCH v3 5/5] qed: Consistency check support

Am 22.10.2010 16:56, schrieb Stefan Hajnoczi:

Quoted 11 lines

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.

Hm, do I understand right that you fix the image and reset the dirty flag in the header during bdrv_open? So how does this work with migration, when the destination host opens the QED file before the source closes it? Doesn't the destination destroy the image by "fixing" it?

And even if that wasn't the case, clearing the flag means that the source might do new writes and thinks that the flag is still set. If the source crashes now, we may need a consistency check, but the dirty flag isn't set any more.

Am I missing some detail?

Kevin

#7 lore raw

Re: [Qemu-devel] Re: [PATCH v3 5/5] qed: Consistency check support

Quoted 18 lines · Kevin Wolf

Am 22.10.2010 16:56, schrieb Stefan Hajnoczi:

Quoted 11 lines

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.

Hm, do I understand right that you fix the image and reset the dirty flag in the header during bdrv_open? So how does this work with migration, when the destination host opens the QED file before the source closes it? Doesn't the destination destroy the image by "fixing" it?

Quoted 6 lines

And even if that wasn't the case, clearing the flag means that the source might do new writes and thinks that the flag is still set. If the source crashes now, we may need a consistency check, but the dirty flag isn't set any more.

Am I missing some detail?

You're right, migration is not supported. This is also true for the other image formats which cache metadata in memory though.

I am actually looking into migration next together with Adam Litke who has already started. We'll have to defer accessing the file until the source has flushed/closed it.

Stefan

#8 lore raw

Re: [Qemu-devel] Re: [PATCH v3 5/5] qed: Consistency check support

Am 28.10.2010 12:15, schrieb Stefan Hajnoczi:

Quoted 24 lines · Kevin Wolf
Quoted 23 lines

Am 22.10.2010 16:56, schrieb Stefan Hajnoczi:

Quoted 11 lines

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.

Hm, do I understand right that you fix the image and reset the dirty flag in the header during bdrv_open? So how does this work with migration, when the destination host opens the QED file before the source closes it? Doesn't the destination destroy the image by "fixing" it?

And even if that wasn't the case, clearing the flag means that the source might do new writes and thinks that the flag is still set. If the source crashes now, we may need a consistency check, but the dirty flag isn't set any more.

Quoted 4 lines
Quoted 1 line

Am I missing some detail?

You're right, migration is not supported. This is also true for the other image formats which cache metadata in memory though.

Is this still broken in upstream? This is a shame.

I think the problem was that Anthony was opposed to reopening the image because we might lose it on that occasion? Instead of possibly crashing a VM in the worst case we regularly corrupt images now... *sigh*

Quoted 3 lines

I am actually looking into migration next together with Adam Litke who has already started. We'll have to defer accessing the file until the source has flushed/closed it.

Sounds to me like an ugly workaround for the fundamental problem that the image file is opened twice at the same time. Ugly because it's not even in a central place, but must be done for each image format separately.

Opening the file read-only first and reopening it read-write when the migration has completed would be much better. No image format driver would have to be changed for that.

Kevin

#9 lore raw

Re: [Qemu-devel] Re: [PATCH v3 5/5] qed: Consistency check support

Quoted 40 lines · Kevin Wolf

Am 28.10.2010 12:15, schrieb Stefan Hajnoczi:

Quoted 24 lines · Kevin Wolf
Quoted 23 lines

Am 22.10.2010 16:56, schrieb Stefan Hajnoczi:

Quoted 11 lines

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.

Hm, do I understand right that you fix the image and reset the dirty flag in the header during bdrv_open? So how does this work with migration, when the destination host opens the QED file before the source closes it? Doesn't the destination destroy the image by "fixing" it?

And even if that wasn't the case, clearing the flag means that the source might do new writes and thinks that the flag is still set. If the source crashes now, we may need a consistency check, but the dirty flag isn't set any more.

Quoted 4 lines
Quoted 1 line

Am I missing some detail?

You're right, migration is not supported.  This is also true for the other image formats which cache metadata in memory though.

Is this still broken in upstream? This is a shame.

I think the problem was that Anthony was opposed to reopening the image because we might lose it on that occasion? Instead of possibly crashing a VM in the worst case we regularly corrupt images now... *sigh*

Quoted 3 lines

I am actually looking into migration next together with Adam Litke who has already started.  We'll have to defer accessing the file until the source has flushed/closed it.

Quoted 7 lines

Sounds to me like an ugly workaround for the fundamental problem that the image file is opened twice at the same time. Ugly because it's not even in a central place, but must be done for each image format separately.

Opening the file read-only first and reopening it read-write when the migration has completed would be much better. No image format driver would have to be changed for that.

I agree. I'm not sure whether NFS guarantees we see the latest data when reopening read-write (cached pages will be left on the destination host from the initial read-only access).

Anyway the solution shouldn't be a massive patch, I'm not too worried about it.

Stefan

#10 lore raw

Re: [Qemu-devel] Re: [PATCH v3 5/5] qed: Consistency check support

Quoted 9 lines · Stefan Hajnoczi
Quoted 4 lines

Opening the file read-only first and reopening it read-write when the migration has completed would be much better. No image format driver would have to be changed for that.

I agree. I'm not sure whether NFS guarantees we see the latest data when reopening read-write (cached pages will be left on the destination host from the initial read-only access).

AFAICT the re-open has to re-validate the metadata. If ctime has changed since the previous stat, the client has to drop local caches.

Signature · 1 line
error compiling committee.c: too many arguments to function