From patchwork Mon Jan 31 15:29:03 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 81156 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 1F154B70EA for ; Tue, 1 Feb 2011 02:48:33 +1100 (EST) Received: from localhost ([127.0.0.1]:36728 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PjvzR-0004Vj-W6 for incoming@patchwork.ozlabs.org; Mon, 31 Jan 2011 10:48:30 -0500 Received: from [140.186.70.92] (port=42972 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pjvfk-0002fx-Bg for qemu-devel@nongnu.org; Mon, 31 Jan 2011 10:28:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PjvfX-0003Rt-BO for qemu-devel@nongnu.org; Mon, 31 Jan 2011 10:27:57 -0500 Received: from mx1.redhat.com ([209.132.183.28]:59862) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PjvfW-0003Rm-U0 for qemu-devel@nongnu.org; Mon, 31 Jan 2011 10:27:55 -0500 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id p0VFRrME008374 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 31 Jan 2011 10:27:53 -0500 Received: from dhcp-5-188.str.redhat.com (dhcp-5-175.str.redhat.com [10.32.5.175]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p0VFRZ2D012144; Mon, 31 Jan 2011 10:27:52 -0500 From: Kevin Wolf To: anthony@codemonkey.ws Date: Mon, 31 Jan 2011 16:29:03 +0100 Message-Id: <1296487756-12553-16-git-send-email-kwolf@redhat.com> In-Reply-To: <1296487756-12553-1-git-send-email-kwolf@redhat.com> References: <1296487756-12553-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH 15/28] qed: Images with backing file do not require QED_F_NEED_CHECK X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: 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 Signed-off-by: Kevin Wolf --- 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); } /**