From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=40980 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pirru-0003O6-2m for qemu-devel@nongnu.org; Fri, 28 Jan 2011 12:12:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Pirrs-00007n-Ao for qemu-devel@nongnu.org; Fri, 28 Jan 2011 12:12:17 -0500 Received: from mtagate5.uk.ibm.com ([194.196.100.165]:34731) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Pirrs-00006S-3C for qemu-devel@nongnu.org; Fri, 28 Jan 2011 12:12:16 -0500 Received: from d06nrmr1507.portsmouth.uk.ibm.com (d06nrmr1507.portsmouth.uk.ibm.com [9.149.38.233]) by mtagate5.uk.ibm.com (8.13.1/8.13.1) with ESMTP id p0SHCDxo014870 for ; Fri, 28 Jan 2011 17:12:13 GMT Received: from d06av01.portsmouth.uk.ibm.com (d06av01.portsmouth.uk.ibm.com [9.149.37.212]) by d06nrmr1507.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p0SHCFa31781994 for ; Fri, 28 Jan 2011 17:12:16 GMT Received: from d06av01.portsmouth.uk.ibm.com (loopback [127.0.0.1]) by d06av01.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p0SHCCXX018124 for ; Fri, 28 Jan 2011 10:12:12 -0700 From: Stefan Hajnoczi Date: Fri, 28 Jan 2011 17:11:59 +0000 Message-Id: <1296234719-2109-1-git-send-email-stefanha@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH] qed: Images with backing file do not require QED_F_NEED_CHECK List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org 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 --- 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