From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=60441 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PijZz-0007sD-Ow for qemu-devel@nongnu.org; Fri, 28 Jan 2011 03:21:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PijZw-000769-PF for qemu-devel@nongnu.org; Fri, 28 Jan 2011 03:21:15 -0500 Received: from mx1.redhat.com ([209.132.183.28]:53148) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PijZw-00075y-H6 for qemu-devel@nongnu.org; Fri, 28 Jan 2011 03:21:12 -0500 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id p0S8LBHc025549 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 28 Jan 2011 03:21:11 -0500 Message-ID: <4D427CD7.8040208@redhat.com> Date: Fri, 28 Jan 2011 09:22:47 +0100 From: Kevin Wolf MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH] qcow2: Add full image preallocation option References: <1296143534-13495-1-git-send-email-kwolf@redhat.com> <20110127155824.GC20364@redhat.com> In-Reply-To: <20110127155824.GC20364@redhat.com> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Daniel P. Berrange" Cc: qemu-devel@nongnu.org Am 27.01.2011 16:58, schrieb Daniel P. Berrange: > On Thu, Jan 27, 2011 at 04:52:14PM +0100, Kevin Wolf wrote: >> This adds a preallocation=full mode to qcow2 image creation, which does not >> only allocate metadata for the whole image, but also writes zeros to it, >> creating a non-sparse image file. >> >> Signed-off-by: Kevin Wolf > Is there a way you can calculate the total size of the qcow2 > file upfront, and just use a single posix_fallocate() call to > do the zero-filled allocation of all the data blocks. It is > many orders of magnitude faster than truely writing blocks of > zero'd data on modern filesystems. I guess if you're using > compression or encryption, we'd really have to go the slow > path, but for regular usage it'd be better to take a fast > path. Encryption doesn't really change anything with respect to cluster allocations, but combining compression with preallocation doesn't make any sense. We should probably forbid that. To get the size of the image, it should be enough to get the offset of the last cluster as the allocation is done sequentially. However, we don't have a bdrv_fallocate (yet). I'm not sure how to emulate this for drivers that don't support it directly, but maybe we could just ignore it for them. So yes, optimizing it should be possible from the qcow2 side of things, but it requires at least some additional code in other places. Kevin