From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36191) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VoFfi-0004VZ-5u for qemu-devel@nongnu.org; Wed, 04 Dec 2013 11:51:42 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VoFfZ-0005fB-On for qemu-devel@nongnu.org; Wed, 04 Dec 2013 11:51:34 -0500 Received: from mx.ipv6.kamp.de ([2a02:248:0:51::16]:46674 helo=mx01.kamp.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VoFfZ-0005ed-Cz for qemu-devel@nongnu.org; Wed, 04 Dec 2013 11:51:25 -0500 Message-ID: <529F5D88.2070709@kamp.de> Date: Wed, 04 Dec 2013 17:51:20 +0100 From: Peter Lieven MIME-Version: 1.0 References: <1385546829-3839-1-git-send-email-pl@kamp.de> <1385546829-3839-2-git-send-email-pl@kamp.de> <20131204164656.GF27759@stefanha-thinkpad.redhat.com> In-Reply-To: <20131204164656.GF27759@stefanha-thinkpad.redhat.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCHv3 1.8 1/9] qemu-img: add support for skipping zeroes in input during convert List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: kwolf@redhat.com, pbonzini@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com Am 04.12.2013 17:46, schrieb Stefan Hajnoczi: > On Wed, Nov 27, 2013 at 11:07:01AM +0100, Peter Lieven wrote: >> + /* If the output image is being created as a copy on write >> + * image, assume that sectors which are unallocated in the >> + * input image are present in both the output's and input's >> + * base images (no need to copy them). */ >> + if (out_baseimg) { >> + if (!(ret & BDRV_BLOCK_DATA)) { >> + sector_num += n1; >> + continue; >> + } >> + /* The next 'n1' sectors are allocated in the input image. >> + * Copy only those as they may be followed by unallocated >> + * sectors. */ >> + nb_sectors = n1; >> + } >> + /* avoid redundant callouts to get_block_status */ >> + sector_num_next_status = sector_num + n1; > Can you explain when we need sector_num_next_status? It's not clear to > me from this patch when we will loop around already knowing that blocks > are allocated. We call get_block_status with MIN(INT_MAX, nb_sectors). So we might receive an allocation status for a huge area. Later we trim the request size to MIN(iobuf_size, nb_sectors) and eventually align the request. For example take a fully allocated image on an iSCSI san. I can easily get that information with the first get_block_status call, but I repeat these calls over and over and in case of the iSCSI SAN these calls are quite expensive. Peter