From patchwork Tue Sep 21 15:21:52 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 65317 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 4AC0FB6EFE for ; Wed, 22 Sep 2010 01:33:33 +1000 (EST) Received: from localhost ([127.0.0.1]:43294 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Oy4qY-0004QB-GF for incoming@patchwork.ozlabs.org; Tue, 21 Sep 2010 11:33:30 -0400 Received: from [140.186.70.92] (port=49585 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Oy4fQ-0008Qm-8T for qemu-devel@nongnu.org; Tue, 21 Sep 2010 11:22:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Oy4fN-0005se-O1 for qemu-devel@nongnu.org; Tue, 21 Sep 2010 11:21:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:7769) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Oy4fN-0005sC-Hd for qemu-devel@nongnu.org; Tue, 21 Sep 2010 11:21:57 -0400 Received: from int-mx08.intmail.prod.int.phx2.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o8LFLrCa030823 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 21 Sep 2010 11:21:55 -0400 Received: from dhcp-5-188.str.redhat.com (dhcp-5-175.str.redhat.com [10.32.5.175]) by int-mx08.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o8LFLZnm016774; Tue, 21 Sep 2010 11:21:49 -0400 From: Kevin Wolf To: anthony@codemonkey.ws Date: Tue, 21 Sep 2010 17:21:52 +0200 Message-Id: <1285082522-24407-11-git-send-email-kwolf@redhat.com> In-Reply-To: <1285082522-24407-1-git-send-email-kwolf@redhat.com> References: <1285082522-24407-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.21 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: kwolf@redhat.com, qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH 10/20] qcow2: Move sync out of qcow2_alloc_clusters 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 Signed-off-by: Kevin Wolf --- block/qcow2-cluster.c | 3 +++ block/qcow2-refcount.c | 4 ++-- block/qcow2-snapshot.c | 2 ++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index f562b16..818c0db 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -60,6 +60,7 @@ int qcow2_grow_l1_table(BlockDriverState *bs, int min_size) qemu_free(new_l1_table); return new_l1_table_offset; } + bdrv_flush(bs->file); BLKDBG_EVENT(bs->file, BLKDBG_L1_GROW_WRITE_TABLE); for(i = 0; i < s->l1_size; i++) @@ -243,6 +244,7 @@ static int l2_allocate(BlockDriverState *bs, int l1_index, uint64_t **table) if (l2_offset < 0) { return l2_offset; } + bdrv_flush(bs->file); /* allocate a new entry in the l2 cache */ @@ -863,6 +865,7 @@ int qcow2_alloc_cluster_offset(BlockDriverState *bs, uint64_t offset, QLIST_REMOVE(m, next_in_flight); return cluster_offset; } + bdrv_flush(bs->file); /* save info needed for meta data update */ m->offset = offset; diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index 4fc3f80..7082601 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -629,8 +629,6 @@ int64_t qcow2_alloc_clusters(BlockDriverState *bs, int64_t size) return ret; } - bdrv_flush(bs->file); - return offset; } @@ -678,6 +676,8 @@ int64_t qcow2_alloc_bytes(BlockDriverState *bs, int size) goto redo; } } + + bdrv_flush(bs->file); return offset; } diff --git a/block/qcow2-snapshot.c b/block/qcow2-snapshot.c index 6228612..bbfcaaa 100644 --- a/block/qcow2-snapshot.c +++ b/block/qcow2-snapshot.c @@ -138,6 +138,7 @@ static int qcow_write_snapshots(BlockDriverState *bs) snapshots_size = offset; snapshots_offset = qcow2_alloc_clusters(bs, snapshots_size); + bdrv_flush(bs->file); offset = snapshots_offset; if (offset < 0) { return offset; @@ -271,6 +272,7 @@ int qcow2_snapshot_create(BlockDriverState *bs, QEMUSnapshotInfo *sn_info) if (l1_table_offset < 0) { goto fail; } + bdrv_flush(bs->file); sn->l1_table_offset = l1_table_offset; sn->l1_size = s->l1_size;