* [Qemu-devel] [PATCH] qed: Images with backing file do not require QED_F_NEED_CHECK
@ 2011-01-28 17:11 Stefan Hajnoczi
2011-01-28 19:48 ` [Qemu-devel] " Kevin Wolf
0 siblings, 1 reply; 2+ messages in thread
From: Stefan Hajnoczi @ 2011-01-28 17:11 UTC (permalink / raw)
To: qemu-devel; +Cc: Kevin Wolf, Stefan Hajnoczi
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>
---
block/qed.c | 24 +++++++++++++++++-------
1 files changed, 17 insertions(+), 7 deletions(-)
diff --git a/block/qed.c b/block/qed.c
index a46f9ef..3273448 100644
--- a/block/qed.c
+++ b/block/qed.c
@@ -977,6 +977,19 @@ static void qed_aio_write_prefill(void *opaque, int ret)
}
/**
+ * 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
*
* @acb: Write request
@@ -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);
}
/**
--
1.7.2.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [Qemu-devel] Re: [PATCH] qed: Images with backing file do not require QED_F_NEED_CHECK
2011-01-28 17:11 [Qemu-devel] [PATCH] qed: Images with backing file do not require QED_F_NEED_CHECK Stefan Hajnoczi
@ 2011-01-28 19:48 ` Kevin Wolf
0 siblings, 0 replies; 2+ messages in thread
From: Kevin Wolf @ 2011-01-28 19:48 UTC (permalink / raw)
To: Stefan Hajnoczi; +Cc: qemu-devel
Am 28.01.2011 18:11, schrieb Stefan Hajnoczi:
> 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>
Thanks, applied to the block branch.
Kevin
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-01-28 19:47 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-28 17:11 [Qemu-devel] [PATCH] qed: Images with backing file do not require QED_F_NEED_CHECK Stefan Hajnoczi
2011-01-28 19:48 ` [Qemu-devel] " Kevin Wolf
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.