Received: from [140.186.70.92] (port=56699 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Owddw-0000HR-4x for qemu-devel@nongnu.org; Fri, 17 Sep 2010 12:18:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Owddq-0001XT-5j for qemu-devel@nongnu.org; Fri, 17 Sep 2010 12:18:32 -0400 Received: from mx1.redhat.com ([209.132.183.28]:1026) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Owddp-0001XM-Tb for qemu-devel@nongnu.org; Fri, 17 Sep 2010 12:18:26 -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 o8HGIPWL017065 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 17 Sep 2010 12:18:25 -0400 From: Kevin Wolf Date: Fri, 17 Sep 2010 18:18:38 +0200 Message-Id: <1284740318-20838-5-git-send-email-kwolf@redhat.com> In-Reply-To: <1284740318-20838-1-git-send-email-kwolf@redhat.com> References: <1284740318-20838-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PATCH 4/4] qcow2: Get rid of additional sync on COW List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com We always have a sync for the refcount update when a new cluster is allocated. If we move this past the COW, we can save an additional sync. Signed-off-by: Kevin Wolf --- block/qcow2-cluster.c | 10 ++++++++-- 1 files changed, 8 insertions(+), 2 deletions(-) diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index 66969c2..634ccef 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -422,7 +422,7 @@ static int copy_sectors(BlockDriverState *bs, uint64_t start_sect, &s->aes_encrypt_key); } BLKDBG_EVENT(bs->file, BLKDBG_COW_WRITE); - ret = bdrv_write_sync(bs->file, (cluster_offset >> 9) + n_start, + ret = bdrv_write(bs->file, (cluster_offset >> 9) + n_start, s->cluster_data, n); if (ret < 0) return ret; @@ -721,6 +721,13 @@ int qcow2_alloc_cluster_link_l2(BlockDriverState *bs, QCowL2Meta *m) (i << s->cluster_bits)) | QCOW_OFLAG_COPIED); } + /* + * Before we update the L2 table to actually point to the new cluster, we + * need to be sure that the refcounts have been increased and COW was + * handled. + */ + bdrv_flush(bs->file); + ret = write_l2_entries(bs, l2_table, l2_offset, l2_index, m->nb_clusters); if (ret < 0) { qcow2_l2_cache_reset(bs); @@ -872,7 +879,6 @@ 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; -- 1.7.2.2