]> git.proxmox.com Git - qemu.git/commitdiff
qed: Images with backing file do not require QED_F_NEED_CHECK
authorStefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Fri, 28 Jan 2011 17:11:59 +0000 (17:11 +0000)
committerKevin Wolf <kwolf@redhat.com>
Mon, 31 Jan 2011 09:03:00 +0000 (10:03 +0100)
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>
block/qed.c

index a46f9ef419478c9ffcdc0cfa829e6cf5fb820657..32734486c59e7a47d381e5a13bce6a0eea6b4335 100644 (file)
@@ -976,6 +976,19 @@ static void qed_aio_write_prefill(void *opaque, int ret)
                                 qed_aio_write_postfill, acb);
 }
 
+/**
+ * Check if the QED_F_NEED_CHECK bit should be set during allocating write
+ */
+static bool qed_should_set_need_check(BDRVQEDState *s)
+{
+    /* The flush before L2 update path ensures consistency */
+    if (s->bs->backing_hd) {
+        return false;
+    }
+
+    return !(s->header.features & QED_F_NEED_CHECK);
+}
+
 /**
  * Write new data cluster
  *
@@ -1001,15 +1014,12 @@ static void qed_aio_write_alloc(QEDAIOCB *acb, size_t len)
     acb->cur_cluster = qed_alloc_clusters(s, acb->cur_nclusters);
     qemu_iovec_copy(&acb->cur_qiov, acb->qiov, acb->qiov_offset, len);
 
-    /* Write new cluster if the image is already marked dirty */
-    if (s->header.features & QED_F_NEED_CHECK) {
+    if (qed_should_set_need_check(s)) {
+        s->header.features |= QED_F_NEED_CHECK;
+        qed_write_header(s, qed_aio_write_prefill, acb);
+    } else {
         qed_aio_write_prefill(acb, 0);
-        return;
     }
-
-    /* Mark the image dirty before writing the new cluster */
-    s->header.features |= QED_F_NEED_CHECK;
-    qed_write_header(s, qed_aio_write_prefill, acb);
 }
 
 /**