[{"id":1765344,"web_url":"http://patchwork.ozlabs.org/comment/1765344/","msgid":"<20170908131518.GI3283@localhost.localdomain>","list_archive_url":null,"date":"2017-09-08T13:15:18","subject":"Re: [Qemu-devel] [PATCH v6 14/18] qcow2: Switch qcow2_measure() to\n\tbyte-based iteration","submitter":{"id":2714,"url":"http://patchwork.ozlabs.org/api/people/2714/","name":"Kevin Wolf","email":"kwolf@redhat.com"},"content":"Am 30.08.2017 um 23:05 hat Eric Blake geschrieben:\n> This is new code, but it is easier to read if it makes passes over\n> the image using bytes rather than sectors (and will get easier in\n> the future when bdrv_get_block_status is converted to byte-based).\n> \n> Signed-off-by: Eric Blake <eblake@redhat.com>\n> Reviewed-by: John Snow <jsnow@redhat.com>\n> \n> ---\n> v6: separate bug fix to earlier patch\n> v5: new patch\n> ---\n>  block/qcow2.c | 22 ++++++++++------------\n>  1 file changed, 10 insertions(+), 12 deletions(-)\n> \n> diff --git a/block/qcow2.c b/block/qcow2.c\n> index 40ba26c111..57e3c5e7d5 100644\n> --- a/block/qcow2.c\n> +++ b/block/qcow2.c\n> @@ -3666,20 +3666,19 @@ static BlockMeasureInfo *qcow2_measure(QemuOpts *opts, BlockDriverState *in_bs,\n>               */\n>              required = virtual_size;\n>          } else {\n> -            int cluster_sectors = cluster_size / BDRV_SECTOR_SIZE;\n> -            int64_t sector_num;\n> +            int64_t offset;\n>              int pnum = 0;\n> \n> -            for (sector_num = 0;\n> -                 sector_num < ssize / BDRV_SECTOR_SIZE;\n> -                 sector_num += pnum) {\n> -                int nb_sectors = MIN(ssize / BDRV_SECTOR_SIZE - sector_num,\n> -                                     BDRV_REQUEST_MAX_SECTORS);\n> +            for (offset = 0; offset < ssize;\n> +                 offset += pnum * BDRV_SECTOR_SIZE) {\n> +                int nb_sectors = MIN(ssize - offset,\n> +                                     INT_MAX) / BDRV_SECTOR_SIZE;\n\nShouldn't this be BDRV_REQUEST_MAX_BYTES? (Which is close to INT_MAX,\nbut rounded down to sector alignment.)\n\nKevin","headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)","ext-mx09.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com","ext-mx09.extmail.prod.ext.phx2.redhat.com;\n\tspf=fail smtp.mailfrom=kwolf@redhat.com"],"Received":["from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xpd9x17bYz9s4s\n\tfor <incoming@patchwork.ozlabs.org>;\n\tFri,  8 Sep 2017 23:16:05 +1000 (AEST)","from localhost ([::1]:45426 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1dqJ8d-0000HO-8W\n\tfor incoming@patchwork.ozlabs.org; Fri, 08 Sep 2017 09:16:03 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:58449)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <kwolf@redhat.com>) id 1dqJ84-0000BK-Hk\n\tfor qemu-devel@nongnu.org; Fri, 08 Sep 2017 09:15:29 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <kwolf@redhat.com>) id 1dqJ83-0001xU-P4\n\tfor qemu-devel@nongnu.org; Fri, 08 Sep 2017 09:15:28 -0400","from mx1.redhat.com ([209.132.183.28]:39298)\n\tby eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <kwolf@redhat.com>)\n\tid 1dqJ80-0001tt-M8; Fri, 08 Sep 2017 09:15:24 -0400","from smtp.corp.redhat.com\n\t(int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby mx1.redhat.com (Postfix) with ESMTPS id C76E24E4CA;\n\tFri,  8 Sep 2017 13:15:23 +0000 (UTC)","from localhost.localdomain (ovpn-116-113.ams2.redhat.com\n\t[10.36.116.113])\n\tby smtp.corp.redhat.com (Postfix) with ESMTPS id 1DD3A614C0;\n\tFri,  8 Sep 2017 13:15:19 +0000 (UTC)"],"DMARC-Filter":"OpenDMARC Filter v1.3.2 mx1.redhat.com C76E24E4CA","Date":"Fri, 8 Sep 2017 15:15:18 +0200","From":"Kevin Wolf <kwolf@redhat.com>","To":"Eric Blake <eblake@redhat.com>","Message-ID":"<20170908131518.GI3283@localhost.localdomain>","References":"<20170830210542.2153-1-eblake@redhat.com>\n\t<20170830210542.2153-15-eblake@redhat.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<20170830210542.2153-15-eblake@redhat.com>","User-Agent":"Mutt/1.8.3 (2017-05-23)","X-Scanned-By":"MIMEDefang 2.79 on 10.5.11.13","X-Greylist":"Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.38]);\n\tFri, 08 Sep 2017 13:15:23 +0000 (UTC)","X-detected-operating-system":"by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]\n\t[fuzzy]","X-Received-From":"209.132.183.28","Subject":"Re: [Qemu-devel] [PATCH v6 14/18] qcow2: Switch qcow2_measure() to\n\tbyte-based iteration","X-BeenThere":"qemu-devel@nongnu.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Id":"<qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<http://lists.nongnu.org/archive/html/qemu-devel/>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Cc":"vsementsov@virtuozzo.com, jsnow@redhat.com, qemu-devel@nongnu.org,\n\tqemu-block@nongnu.org, Max Reitz <mreitz@redhat.com>","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>"}},{"id":1765373,"web_url":"http://patchwork.ozlabs.org/comment/1765373/","msgid":"<0afaa754-a5a1-2c0a-af5d-4ba5bd152d17@redhat.com>","list_archive_url":null,"date":"2017-09-08T13:43:06","subject":"Re: [Qemu-devel] [PATCH v6 14/18] qcow2: Switch qcow2_measure() to\n\tbyte-based iteration","submitter":{"id":6591,"url":"http://patchwork.ozlabs.org/api/people/6591/","name":"Eric Blake","email":"eblake@redhat.com"},"content":"On 09/08/2017 08:15 AM, Kevin Wolf wrote:\n> Am 30.08.2017 um 23:05 hat Eric Blake geschrieben:\n>> This is new code, but it is easier to read if it makes passes over\n>> the image using bytes rather than sectors (and will get easier in\n>> the future when bdrv_get_block_status is converted to byte-based).\n>>\n>> Signed-off-by: Eric Blake <eblake@redhat.com>\n>> Reviewed-by: John Snow <jsnow@redhat.com>\n>>\n\n>> -                int nb_sectors = MIN(ssize / BDRV_SECTOR_SIZE - sector_num,\n>> -                                     BDRV_REQUEST_MAX_SECTORS);\n>> +            for (offset = 0; offset < ssize;\n>> +                 offset += pnum * BDRV_SECTOR_SIZE) {\n>> +                int nb_sectors = MIN(ssize - offset,\n>> +                                     INT_MAX) / BDRV_SECTOR_SIZE;\n> \n> Shouldn't this be BDRV_REQUEST_MAX_BYTES? (Which is close to INT_MAX,\n> but rounded down to sector alignment.)\n\nThe division rounds down to sector alignment after the MIN(), for the\nsame result in nb_sectors either way.  But you are correct that an\nabsolutely literal translation of the pre-patch version would feed\nBDRV_REQUEST_MAX_BYTES instead of INT_MAX into the MIN().","headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)","ext-mx09.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com","ext-mx09.extmail.prod.ext.phx2.redhat.com;\n\tspf=fail smtp.mailfrom=eblake@redhat.com"],"Received":["from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xpdnx4czQz9s83\n\tfor <incoming@patchwork.ozlabs.org>;\n\tFri,  8 Sep 2017 23:43:49 +1000 (AEST)","from localhost ([::1]:45499 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1dqJZT-0002q3-Qq\n\tfor incoming@patchwork.ozlabs.org; Fri, 08 Sep 2017 09:43:47 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:38090)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <eblake@redhat.com>) id 1dqJZ5-0002oq-UE\n\tfor qemu-devel@nongnu.org; Fri, 08 Sep 2017 09:43:27 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <eblake@redhat.com>) id 1dqJZ2-0006ax-R6\n\tfor qemu-devel@nongnu.org; Fri, 08 Sep 2017 09:43:21 -0400","from mx1.redhat.com ([209.132.183.28]:59654)\n\tby eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <eblake@redhat.com>)\n\tid 1dqJYw-0006VI-WF; Fri, 08 Sep 2017 09:43:15 -0400","from smtp.corp.redhat.com\n\t(int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby mx1.redhat.com (Postfix) with ESMTPS id 1172C4E049;\n\tFri,  8 Sep 2017 13:43:14 +0000 (UTC)","from [10.10.120.228] (ovpn-120-228.rdu2.redhat.com [10.10.120.228])\n\tby smtp.corp.redhat.com (Postfix) with ESMTP id 231C16061E;\n\tFri,  8 Sep 2017 13:43:09 +0000 (UTC)"],"DMARC-Filter":"OpenDMARC Filter v1.3.2 mx1.redhat.com 1172C4E049","To":"Kevin Wolf <kwolf@redhat.com>","References":"<20170830210542.2153-1-eblake@redhat.com>\n\t<20170830210542.2153-15-eblake@redhat.com>\n\t<20170908131518.GI3283@localhost.localdomain>","From":"Eric Blake <eblake@redhat.com>","Openpgp":"url=http://people.redhat.com/eblake/eblake.gpg","Organization":"Red Hat, Inc.","Message-ID":"<0afaa754-a5a1-2c0a-af5d-4ba5bd152d17@redhat.com>","Date":"Fri, 8 Sep 2017 08:43:06 -0500","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101\n\tThunderbird/52.3.0","MIME-Version":"1.0","In-Reply-To":"<20170908131518.GI3283@localhost.localdomain>","Content-Type":"multipart/signed; micalg=pgp-sha256;\n\tprotocol=\"application/pgp-signature\";\n\tboundary=\"RvSmAoT4oU9dFcKPhLOBX7XlFmwjUbB3d\"","X-Scanned-By":"MIMEDefang 2.79 on 10.5.11.13","X-Greylist":"Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.38]);\n\tFri, 08 Sep 2017 13:43:14 +0000 (UTC)","X-detected-operating-system":"by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]\n\t[fuzzy]","X-Received-From":"209.132.183.28","X-Content-Filtered-By":"Mailman/MimeDel 2.1.21","Subject":"Re: [Qemu-devel] [PATCH v6 14/18] qcow2: Switch qcow2_measure() to\n\tbyte-based iteration","X-BeenThere":"qemu-devel@nongnu.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Id":"<qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<http://lists.nongnu.org/archive/html/qemu-devel/>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Cc":"vsementsov@virtuozzo.com, jsnow@redhat.com, qemu-devel@nongnu.org,\n\tqemu-block@nongnu.org, Max Reitz <mreitz@redhat.com>","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>"}}]