From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36590) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VK2dN-0007LN-CY for qemu-devel@nongnu.org; Thu, 12 Sep 2013 04:52:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VK2dE-0004yt-UY for qemu-devel@nongnu.org; Thu, 12 Sep 2013 04:52:17 -0400 Received: from mx.ipv6.kamp.de ([2a02:248:0:51::16]:56177 helo=mx01.kamp.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VK2dE-0004yT-Dt for qemu-devel@nongnu.org; Thu, 12 Sep 2013 04:52:08 -0400 Message-ID: <523180B3.8050209@kamp.de> Date: Thu, 12 Sep 2013 10:52:03 +0200 From: Peter Lieven MIME-Version: 1.0 References: <1373885375-13601-5-git-send-email-pl@kamp.de> <20130717084648.GD2458@dhcp-200-207.str.redhat.com> <51E66ACD.70706@redhat.com> <20130717102551.GF2458@dhcp-200-207.str.redhat.com> <51E6C5FC.1030304@redhat.com> <7C1EEB41-E2B3-4186-9188-379F02E76FF9@kamp.de> <51E6CE81.6000400@redhat.com> <36C25446-54C7-4D1F-9D8D-E8A3991489BD@kamp.de> <20130718092316.GG3582@dhcp-200-207.str.redhat.com> <51E7C260.50404@redhat.com> <51E7C707.7010101@kamp.de> <51E7C9C4.5010202@redhat.com> <51E7CBC8.1010804@kamp.de> <51E7E035.3010702@redhat.com> <51E7EDD0.6050001@kamp.de> <51E7F84C.2080705@redhat.com> In-Reply-To: <51E7F84C.2080705@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 4/4] qemu-img: conditionally discard target on convert List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: Kevin Wolf , Stefan Hajnoczi , qemu-devel , ronnie sahlberg On 18.07.2013 16:14, Paolo Bonzini wrote: > Il 18/07/2013 15:55, ronnie sahlberg ha scritto: >>>> bdrv->write_zeroes will use writesame16 and set the unmap flag only if >>>> BDRV_MAY_DISCARD == 1 and BDRV_O_UNMAP == 1 and lbprz == 1. >> When you use WRITESAME16 you can ignore the lbprz flag. >> Just send a WRITESAME16 command with one block of data that is all set to zero. >> If the unmap flag is set and if unmapped blocks read back the same as >> the block you provided (all zero) >> then it will unmap those blocks, where possible. > True, so the unmap flag can be set iff BDRV_MAY_DISCARD == 1. block.c > can take care of checking BDRV_O_UNMAP. Would you add BDRV_MAY_DISCARD to BdrvRequestFlags? This would require making BdrvRequestFlags public. Before I start implementation I would still like to verify if we need this flag. E.g. in which case would we do not want to optimize writing zeroes via discard if the user has set BDRV_O_UNMAP? One case I would think of is sanitizing data. But in this case shouldn't this be a different function? In case of a container format its also not guaranteed that the contents are erased from the underlying media. Looking at the commit message for f08f2ddae078e8a7683f8b16da8e0cc3029c7b89 it sounds that bdrv_write_zeroes was intended to provide an efficient way to zero contents, but only in the sense that it is guaranteed that they read back as zero (compared to bdrv_discard). Peter