From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54107) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X4zZ1-0008AY-HS for qemu-devel@nongnu.org; Wed, 09 Jul 2014 17:38:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X4zYv-0005xn-DY for qemu-devel@nongnu.org; Wed, 09 Jul 2014 17:38:07 -0400 Received: from mx1.redhat.com ([209.132.183.28]:30682) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X4zYv-0005xQ-3h for qemu-devel@nongnu.org; Wed, 09 Jul 2014 17:38:01 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s69Lc0TB012393 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 9 Jul 2014 17:38:00 -0400 Message-ID: <53BDB63B.6030503@redhat.com> Date: Wed, 09 Jul 2014 23:38:03 +0200 From: Max Reitz MIME-Version: 1.0 References: <1404582448-23840-1-git-send-email-mreitz@redhat.com> <1404582448-23840-4-git-send-email-mreitz@redhat.com> <53BDB280.6080408@redhat.com> In-Reply-To: <53BDB280.6080408@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v9 03/14] qcow2: Optimize bdrv_make_empty() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini , qemu-devel@nongnu.org Cc: Kevin Wolf , Stefan Hajnoczi On 09.07.2014 23:22, Paolo Bonzini wrote: > Il 05/07/2014 19:47, Max Reitz ha scritto: >> bdrv_make_empty() is currently only called if the current image >> represents an external snapshot that has been committed to its base >> image; it is therefore unlikely to have internal snapshots. In this >> case, bdrv_make_empty() can be greatly sped up by creating an empty L1 >> table and dropping all data clusters at once by recreating the refcount >> structure accordingly instead of normally discarding all clusters. >> >> If there are snapshots, fall back to the simple implementation (discard >> all clusters). > > How much of this code could be reused by bdrv_create? Currently, none. The latest version of Hu Tao's preallocation series reuses minimal_blob_size(). The point of this code is to empty an image at runtime while keeping it consistent all the time. bdrv_open() does not have that problem; there are no pre-existing structures, therefore it can just go and create them. bdrv_make_empty() has to be careful (in this version) not to overwrite any data or metadata while relocating the structures. Kevin proposed another version which just marks the image dirty, clears the L1 table, relocates it and then writes minimal refcount structures. This will be shorted and in principle similar to how bdrv_open() works, but isn't worth sharing either. Max