From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55225) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Whwqe-000667-DB for qemu-devel@nongnu.org; Wed, 07 May 2014 04:05:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WhwqY-0002h2-9G for qemu-devel@nongnu.org; Wed, 07 May 2014 04:05:04 -0400 Received: from mx1.redhat.com ([209.132.183.28]:15768) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WhwqY-0002gx-2A for qemu-devel@nongnu.org; Wed, 07 May 2014 04:04:58 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s4784vtt012220 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 7 May 2014 04:04:57 -0400 Date: Wed, 7 May 2014 10:04:56 +0200 From: Stefan Hajnoczi Message-ID: <20140507080456.GC27925@stefanha-thinkpad.muc.redhat.com> References: <1399343564-17687-1-git-send-email-famz@redhat.com> <20140507014517.GG1574@T430.nay.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20140507014517.GG1574@T430.nay.redhat.com> Subject: Re: [Qemu-devel] [PATCH v2] vmdk: Optimize cluster allocation List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Fam Zheng Cc: Kevin Wolf , qemu-devel@nongnu.org On Wed, May 07, 2014 at 09:45:17AM +0800, Fam Zheng wrote: > On Tue, 05/06 10:32, Fam Zheng wrote: > > @@ -1110,12 +1111,20 @@ static int get_cluster_offset(BlockDriverState *bs, > > } > > > > /* Avoid the L2 tables update for the images that have snapshots. */ > > - *cluster_offset = bdrv_getlength(extent->file); > > + ret = bdrv_getlength(extent->file); > > + if (ret < 0 || > > + ret & ((extent->cluster_sectors << BDRV_SECTOR_BITS) - 1)) { > > + return VMDK_ERROR; > > + } > > + *cluster_offset = ret; > > if (!extent->compressed) { > > - bdrv_truncate( > > - extent->file, > > - *cluster_offset + (extent->cluster_sectors << 9) > > - ); > > + ret = bdrv_write_zeroes(extent->file, > > + *cluster_offset >> BDRV_SECTOR_BITS, > > + extent->cluster_sectors, > > + 0); > > Hi Stefan, > > By considering a bdrv_write_zeroes as a pre-write, it in general doubles the > write for the whole image, so it's not a good solution. > > A better way would be removing the bdrv_truncate and require the caller to do > full cluster write (with a bounce buffer if necessary). > > So let's drop this patch. Okay, thanks for investigating this. Stefan