[{"id":1774994,"web_url":"http://patchwork.ozlabs.org/comment/1774994/","msgid":"<824a08a4-a8cd-8f5c-18b6-2f3c44eca124@redhat.com>","list_archive_url":null,"date":"2017-09-25T21:44:33","subject":"Re: [Qemu-devel] [PATCH v2 2/2] qcow2: truncate the tail of the\n\timage file after shrinking the image","submitter":{"id":64343,"url":"http://patchwork.ozlabs.org/api/people/64343/","name":"John Snow","email":"jsnow@redhat.com"},"content":"On 09/22/2017 05:39 AM, Pavel Butsykin wrote:\n> Now after shrinking the image, at the end of the image file, there might be a\n> tail that probably will never be used. So we can find the last used cluster and\n> cut the tail.\n> \n> Signed-off-by: Pavel Butsykin <pbutsykin@virtuozzo.com>\n\n\nReviewed-by: John Snow <jsnow@redhat.com>","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-mx05.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com","ext-mx05.extmail.prod.ext.phx2.redhat.com;\n\tspf=fail smtp.mailfrom=jsnow@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 3y1Hgb467fz9t2S\n\tfor <incoming@patchwork.ozlabs.org>;\n\tTue, 26 Sep 2017 07:45:07 +1000 (AEST)","from localhost ([::1]:44405 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 1dwbBX-0003Gb-Jm\n\tfor incoming@patchwork.ozlabs.org; Mon, 25 Sep 2017 17:45:03 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:45312)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <jsnow@redhat.com>) id 1dwbBB-0003EE-FS\n\tfor qemu-devel@nongnu.org; Mon, 25 Sep 2017 17:44:42 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <jsnow@redhat.com>) id 1dwbBA-0000Ep-Rh\n\tfor qemu-devel@nongnu.org; Mon, 25 Sep 2017 17:44:41 -0400","from mx1.redhat.com ([209.132.183.28]:34402)\n\tby eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <jsnow@redhat.com>)\n\tid 1dwbB6-0000BB-8V; Mon, 25 Sep 2017 17:44:36 -0400","from smtp.corp.redhat.com\n\t(int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14])\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 287A513AAE;\n\tMon, 25 Sep 2017 21:44:35 +0000 (UTC)","from [10.18.17.130] (dhcp-17-130.bos.redhat.com [10.18.17.130])\n\tby smtp.corp.redhat.com (Postfix) with ESMTP id 2B9A65D9C1;\n\tMon, 25 Sep 2017 21:44:34 +0000 (UTC)"],"DMARC-Filter":"OpenDMARC Filter v1.3.2 mx1.redhat.com 287A513AAE","To":"Pavel Butsykin <pbutsykin@virtuozzo.com>, qemu-block@nongnu.org,\n\tqemu-devel@nongnu.org","References":"<20170922093926.9723-1-pbutsykin@virtuozzo.com>\n\t<20170922093926.9723-3-pbutsykin@virtuozzo.com>","From":"John Snow <jsnow@redhat.com>","Message-ID":"<824a08a4-a8cd-8f5c-18b6-2f3c44eca124@redhat.com>","Date":"Mon, 25 Sep 2017 17:44:33 -0400","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":"<20170922093926.9723-3-pbutsykin@virtuozzo.com>","Content-Type":"text/plain; charset=utf-8","Content-Language":"en-US","Content-Transfer-Encoding":"7bit","X-Scanned-By":"MIMEDefang 2.79 on 10.5.11.14","X-Greylist":"Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.29]);\n\tMon, 25 Sep 2017 21:44:35 +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 v2 2/2] qcow2: truncate the tail of the\n\timage file after shrinking the image","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":"kwolf@redhat.com, den@openvz.org, 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":1776451,"web_url":"http://patchwork.ozlabs.org/comment/1776451/","msgid":"<46949467-5bed-602b-5d64-badf92c059e1@redhat.com>","list_archive_url":null,"date":"2017-09-27T16:00:49","subject":"Re: [Qemu-devel] [PATCH v2 2/2] qcow2: truncate the tail of the\n\timage file after shrinking the image","submitter":{"id":36836,"url":"http://patchwork.ozlabs.org/api/people/36836/","name":"Max Reitz","email":"mreitz@redhat.com"},"content":"On 2017-09-22 11:39, Pavel Butsykin wrote:\n> Now after shrinking the image, at the end of the image file, there might be a\n> tail that probably will never be used. So we can find the last used cluster and\n> cut the tail.\n> \n> Signed-off-by: Pavel Butsykin <pbutsykin@virtuozzo.com>\n> ---\n>  block/qcow2-refcount.c | 22 ++++++++++++++++++++++\n>  block/qcow2.c          | 23 +++++++++++++++++++++++\n>  block/qcow2.h          |  1 +\n>  3 files changed, 46 insertions(+)\n> \n> diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c\n> index 88d5a3f1ad..aa3fd6cf17 100644\n> --- a/block/qcow2-refcount.c\n> +++ b/block/qcow2-refcount.c\n> @@ -3181,3 +3181,25 @@ out:\n>      g_free(reftable_tmp);\n>      return ret;\n>  }\n> +\n> +int64_t qcow2_get_last_cluster(BlockDriverState *bs, int64_t size)\n> +{\n> +    BDRVQcow2State *s = bs->opaque;\n> +    int64_t i;\n> +\n> +    for (i = size_to_clusters(s, size) - 1; i >= 0; i--) {\n> +        uint64_t refcount;\n> +        int ret = qcow2_get_refcount(bs, i, &refcount);\n> +        if (ret < 0) {\n> +            fprintf(stderr, \"Can't get refcount for cluster %\" PRId64 \": %s\\n\",\n> +                    i, strerror(-ret));\n> +            return ret;\n> +        }\n> +        if (refcount > 0) {\n> +            return i;\n> +        }\n> +    }\n> +    qcow2_signal_corruption(bs, true, -1, -1,\n> +                            \"There are no references in the refcount table.\");\n> +    return -EIO;\n> +}\n> diff --git a/block/qcow2.c b/block/qcow2.c\n> index 8a4311d338..8dfb5393a7 100644\n> --- a/block/qcow2.c\n> +++ b/block/qcow2.c\n> @@ -3106,6 +3106,7 @@ static int qcow2_truncate(BlockDriverState *bs, int64_t offset,\n>      new_l1_size = size_to_l1(s, offset);\n>  \n>      if (offset < old_length) {\n> +        int64_t last_cluster, old_file_size;\n>          if (prealloc != PREALLOC_MODE_OFF) {\n>              error_setg(errp,\n>                         \"Preallocation can't be used for shrinking an image\");\n> @@ -3134,6 +3135,28 @@ static int qcow2_truncate(BlockDriverState *bs, int64_t offset,\n>                               \"Failed to discard unused refblocks\");\n>              return ret;\n>          }\n> +\n> +        old_file_size = bdrv_getlength(bs->file->bs);\n> +        if (old_file_size < 0) {\n> +            error_setg_errno(errp, -old_file_size,\n> +                             \"Failed to inquire current file length\");\n> +            return old_file_size;\n> +        }\n> +        last_cluster = qcow2_get_last_cluster(bs, old_file_size);\n> +        if (last_cluster < 0) {\n> +            error_setg_errno(errp, -last_cluster,\n> +                             \"Failed to find the last cluster\");\n> +            return last_cluster;\n> +        }\n\nMy idea was rather that you just wouldn't truncate the image file if\nsomething fails here.  So in any of these new cases where you currently\njust report the whole truncate operation as having failed, you could\njust emit a warning and not do the truncation of bs->file.\n\nI can live with the current version, though, so:\n\nReviewed-by: Max Reitz <mreitz@redhat.com>\n\nBut I'll wait for a response from you before merging this series.\n\nMax\n\n> +        if ((last_cluster + 1) * s->cluster_size < old_file_size) {\n> +            ret = bdrv_truncate(bs->file, (last_cluster + 1) * s->cluster_size,\n> +                                PREALLOC_MODE_OFF, NULL);\n> +            if (ret < 0) {\n> +                error_setg_errno(errp, -ret,\n> +                                 \"Failed to truncate the tail of the image\");\n> +                return ret;\n> +            }\n> +        }\n>      } else {\n>          ret = qcow2_grow_l1_table(bs, new_l1_size, true);\n>          if (ret < 0) {\n> diff --git a/block/qcow2.h b/block/qcow2.h\n> index 5a289a81e2..782a206ecb 100644\n> --- a/block/qcow2.h\n> +++ b/block/qcow2.h\n> @@ -597,6 +597,7 @@ int qcow2_change_refcount_order(BlockDriverState *bs, int refcount_order,\n>                                  BlockDriverAmendStatusCB *status_cb,\n>                                  void *cb_opaque, Error **errp);\n>  int qcow2_shrink_reftable(BlockDriverState *bs);\n> +int64_t qcow2_get_last_cluster(BlockDriverState *bs, int64_t size);\n>  \n>  /* qcow2-cluster.c functions */\n>  int qcow2_grow_l1_table(BlockDriverState *bs, uint64_t min_size,\n>","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-mx02.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com","ext-mx02.extmail.prod.ext.phx2.redhat.com;\n\tspf=fail smtp.mailfrom=mreitz@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 3y2N0Z5rvvz9sRg\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu, 28 Sep 2017 02:03:36 +1000 (AEST)","from localhost ([::1]:55448 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 1dxEo6-0007Tr-NY\n\tfor incoming@patchwork.ozlabs.org; Wed, 27 Sep 2017 12:03:30 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:44594)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <mreitz@redhat.com>) id 1dxElx-0006Fb-Br\n\tfor qemu-devel@nongnu.org; Wed, 27 Sep 2017 12:01:23 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <mreitz@redhat.com>) id 1dxElr-0006e9-DD\n\tfor qemu-devel@nongnu.org; Wed, 27 Sep 2017 12:01:17 -0400","from mx1.redhat.com ([209.132.183.28]:24659)\n\tby eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <mreitz@redhat.com>)\n\tid 1dxElf-0006Y4-7z; Wed, 27 Sep 2017 12:00:59 -0400","from smtp.corp.redhat.com\n\t(int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11])\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 51DBCF1D83;\n\tWed, 27 Sep 2017 16:00:57 +0000 (UTC)","from dresden.str.redhat.com (unknown [10.40.205.58])\n\tby smtp.corp.redhat.com (Postfix) with ESMTPS id 6C99288D8C;\n\tWed, 27 Sep 2017 16:00:52 +0000 (UTC)"],"DMARC-Filter":"OpenDMARC Filter v1.3.2 mx1.redhat.com 51DBCF1D83","To":"Pavel Butsykin <pbutsykin@virtuozzo.com>, qemu-block@nongnu.org,\n\tqemu-devel@nongnu.org","References":"<20170922093926.9723-1-pbutsykin@virtuozzo.com>\n\t<20170922093926.9723-3-pbutsykin@virtuozzo.com>","From":"Max Reitz <mreitz@redhat.com>","Message-ID":"<46949467-5bed-602b-5d64-badf92c059e1@redhat.com>","Date":"Wed, 27 Sep 2017 18:00:49 +0200","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":"<20170922093926.9723-3-pbutsykin@virtuozzo.com>","Content-Type":"multipart/signed; micalg=pgp-sha256;\n\tprotocol=\"application/pgp-signature\";\n\tboundary=\"WhHVSbO4dv0devgFsHciVsA8do5lihTBE\"","X-Scanned-By":"MIMEDefang 2.79 on 10.5.11.11","X-Greylist":"Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.26]);\n\tWed, 27 Sep 2017 16:00:57 +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 v2 2/2] qcow2: truncate the tail of the\n\timage file after shrinking the image","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":"kwolf@redhat.com, jsnow@redhat.com, den@openvz.org","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":1776470,"web_url":"http://patchwork.ozlabs.org/comment/1776470/","msgid":"<6a53fa30-03b0-cd04-ef12-e41656e78900@virtuozzo.com>","list_archive_url":null,"date":"2017-09-27T16:27:58","subject":"Re: [Qemu-devel] [PATCH v2 2/2] qcow2: truncate the tail of the\n\timage file after shrinking the image","submitter":{"id":67271,"url":"http://patchwork.ozlabs.org/api/people/67271/","name":"Pavel Butsykin","email":"pbutsykin@virtuozzo.com"},"content":"On 27.09.2017 19:00, Max Reitz wrote:\n> On 2017-09-22 11:39, Pavel Butsykin wrote:\n>> Now after shrinking the image, at the end of the image file, there might be a\n>> tail that probably will never be used. So we can find the last used cluster and\n>> cut the tail.\n>>\n>> Signed-off-by: Pavel Butsykin <pbutsykin@virtuozzo.com>\n>> ---\n>>   block/qcow2-refcount.c | 22 ++++++++++++++++++++++\n>>   block/qcow2.c          | 23 +++++++++++++++++++++++\n>>   block/qcow2.h          |  1 +\n>>   3 files changed, 46 insertions(+)\n>>\n>> diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c\n>> index 88d5a3f1ad..aa3fd6cf17 100644\n>> --- a/block/qcow2-refcount.c\n>> +++ b/block/qcow2-refcount.c\n>> @@ -3181,3 +3181,25 @@ out:\n>>       g_free(reftable_tmp);\n>>       return ret;\n>>   }\n>> +\n>> +int64_t qcow2_get_last_cluster(BlockDriverState *bs, int64_t size)\n>> +{\n>> +    BDRVQcow2State *s = bs->opaque;\n>> +    int64_t i;\n>> +\n>> +    for (i = size_to_clusters(s, size) - 1; i >= 0; i--) {\n>> +        uint64_t refcount;\n>> +        int ret = qcow2_get_refcount(bs, i, &refcount);\n>> +        if (ret < 0) {\n>> +            fprintf(stderr, \"Can't get refcount for cluster %\" PRId64 \": %s\\n\",\n>> +                    i, strerror(-ret));\n>> +            return ret;\n>> +        }\n>> +        if (refcount > 0) {\n>> +            return i;\n>> +        }\n>> +    }\n>> +    qcow2_signal_corruption(bs, true, -1, -1,\n>> +                            \"There are no references in the refcount table.\");\n>> +    return -EIO;\n>> +}\n>> diff --git a/block/qcow2.c b/block/qcow2.c\n>> index 8a4311d338..8dfb5393a7 100644\n>> --- a/block/qcow2.c\n>> +++ b/block/qcow2.c\n>> @@ -3106,6 +3106,7 @@ static int qcow2_truncate(BlockDriverState *bs, int64_t offset,\n>>       new_l1_size = size_to_l1(s, offset);\n>>   \n>>       if (offset < old_length) {\n>> +        int64_t last_cluster, old_file_size;\n>>           if (prealloc != PREALLOC_MODE_OFF) {\n>>               error_setg(errp,\n>>                          \"Preallocation can't be used for shrinking an image\");\n>> @@ -3134,6 +3135,28 @@ static int qcow2_truncate(BlockDriverState *bs, int64_t offset,\n>>                                \"Failed to discard unused refblocks\");\n>>               return ret;\n>>           }\n>> +\n>> +        old_file_size = bdrv_getlength(bs->file->bs);\n>> +        if (old_file_size < 0) {\n>> +            error_setg_errno(errp, -old_file_size,\n>> +                             \"Failed to inquire current file length\");\n>> +            return old_file_size;\n>> +        }\n>> +        last_cluster = qcow2_get_last_cluster(bs, old_file_size);\n>> +        if (last_cluster < 0) {\n>> +            error_setg_errno(errp, -last_cluster,\n>> +                             \"Failed to find the last cluster\");\n>> +            return last_cluster;\n>> +        }\n> \n> My idea was rather that you just wouldn't truncate the image file if\n> something fails here.  So in any of these new cases where you currently\n> just report the whole truncate operation as having failed, you could\n> just emit a warning and not do the truncation of bs->file.\n\nI'm not sure that's right. If the qcow2_get_last_cluster() returned an\nerror, probably with the image was a problem.. can we continue to work\nwith the image without risking to damage it even more? if something bad\nhappened with the reftable we usually mark the image as corrupted, it's\nthe same thing.\n\nAlthough if the shrink is almost complete, the truncation of bs->file\nisn't so important thing and we could update qcow2 header.\n\n> I can live with the current version, though, so:\n> \n> Reviewed-by: Max Reitz <mreitz@redhat.com>\n> \n> But I'll wait for a response from you before merging this series.\n> \n> Max\n> \n>> +        if ((last_cluster + 1) * s->cluster_size < old_file_size) {\n>> +            ret = bdrv_truncate(bs->file, (last_cluster + 1) * s->cluster_size,\n>> +                                PREALLOC_MODE_OFF, NULL);\n>> +            if (ret < 0) {\n>> +                error_setg_errno(errp, -ret,\n>> +                                 \"Failed to truncate the tail of the image\");\n>> +                return ret;\n>> +            }\n>> +        }\n>>       } else {\n>>           ret = qcow2_grow_l1_table(bs, new_l1_size, true);\n>>           if (ret < 0) {\n>> diff --git a/block/qcow2.h b/block/qcow2.h\n>> index 5a289a81e2..782a206ecb 100644\n>> --- a/block/qcow2.h\n>> +++ b/block/qcow2.h\n>> @@ -597,6 +597,7 @@ int qcow2_change_refcount_order(BlockDriverState *bs, int refcount_order,\n>>                                   BlockDriverAmendStatusCB *status_cb,\n>>                                   void *cb_opaque, Error **errp);\n>>   int qcow2_shrink_reftable(BlockDriverState *bs);\n>> +int64_t qcow2_get_last_cluster(BlockDriverState *bs, int64_t size);\n>>   \n>>   /* qcow2-cluster.c functions */\n>>   int qcow2_grow_l1_table(BlockDriverState *bs, uint64_t min_size,\n>>\n> \n>","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>)","ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=virtuozzo.com header.i=@virtuozzo.com\n\theader.b=\"BWFP2PMX\"; dkim-atps=neutral","spf=none (sender IP is )\n\tsmtp.mailfrom=pbutsykin@virtuozzo.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 3y2NYl0jFHz9t5l\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu, 28 Sep 2017 02:28:57 +1000 (AEST)","from localhost ([::1]:55538 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 1dxFCg-0007ts-4u\n\tfor incoming@patchwork.ozlabs.org; Wed, 27 Sep 2017 12:28:54 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:51130)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <pbutsykin@virtuozzo.com>) id 1dxFCH-0007tg-2k\n\tfor qemu-devel@nongnu.org; Wed, 27 Sep 2017 12:28:30 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <pbutsykin@virtuozzo.com>) id 1dxFCB-00052W-1y\n\tfor qemu-devel@nongnu.org; Wed, 27 Sep 2017 12:28:29 -0400","from mail-eopbgr20131.outbound.protection.outlook.com\n\t([40.107.2.131]:63736\n\thelo=EUR02-VE1-obe.outbound.protection.outlook.com)\n\tby eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <pbutsykin@virtuozzo.com>)\n\tid 1dxFCA-00050I-Dl; Wed, 27 Sep 2017 12:28:22 -0400","from [172.16.25.50] (195.214.232.6) by\n\tVI1PR0802MB2559.eurprd08.prod.outlook.com (2603:10a6:800:ae::9) with\n\tMicrosoft SMTP Server (version=TLS1_2,\n\tcipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.77.7;\n\tWed, 27 Sep 2017 16:28:17 +0000"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com;\n\ts=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version;\n\tbh=sZuV4NO20Bqx+9UlXq1O8Ym7rFSDVkDpQTbzDCbH6zE=;\n\tb=BWFP2PMXGTYBhOWR5/X+FMbFmBswpf4l2G6KKjnYuo7ix+TsgJz8vu87jVhyTV8X6iO7HQVIpi9uy9GdsBdAHC4FTxnk/VbQe6xsPH5nuSe89aSHmaq+YfuIejC+tV1Ebd8V8+O4PfuqlyFhud7GepWidN5SC64h/BcxD1UFdZ4=","To":"Max Reitz <mreitz@redhat.com>, qemu-block@nongnu.org,\n\tqemu-devel@nongnu.org","References":"<20170922093926.9723-1-pbutsykin@virtuozzo.com>\n\t<20170922093926.9723-3-pbutsykin@virtuozzo.com>\n\t<46949467-5bed-602b-5d64-badf92c059e1@redhat.com>","From":"Pavel Butsykin <pbutsykin@virtuozzo.com>","Message-ID":"<6a53fa30-03b0-cd04-ef12-e41656e78900@virtuozzo.com>","Date":"Wed, 27 Sep 2017 19:27:58 +0300","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101\n\tThunderbird/52.2.1","MIME-Version":"1.0","In-Reply-To":"<46949467-5bed-602b-5d64-badf92c059e1@redhat.com>","Content-Type":"text/plain; charset=utf-8; format=flowed","Content-Language":"en-US","Content-Transfer-Encoding":"7bit","X-Originating-IP":"[195.214.232.6]","X-ClientProxiedBy":"HE1PR0401CA0084.eurprd04.prod.outlook.com\n\t(2603:10a6:3:19::52) To VI1PR0802MB2559.eurprd08.prod.outlook.com\n\t(2603:10a6:800:ae::9)","X-MS-PublicTrafficType":"Email","X-MS-Office365-Filtering-Correlation-Id":"7daa5345-97b0-47cd-7b3e-08d505c4c2b1","X-Microsoft-Antispam":"UriScan:; BCL:0; PCL:0;\n\tRULEID:(22001)(2017030254152)(2017052603199)(201703131423075)(201703031133081)(201702281549075);\n\tSRVR:VI1PR0802MB2559; ","X-Microsoft-Exchange-Diagnostics":["1; VI1PR0802MB2559;\n\t3:sK26wThmG8iJg51AXCBPSjp2qDj/qr/2aDDtO78G042LV5yyv6XyFx+SVv4vaV6uMS6c6aCWdzVYcx6XsBnEUqT1c4VcmQvZF2rrQ+i0EgQi1h8hm+gKGL/36PPK2xSqAys055AJecrDcwd3jbzpwm0tF7ORiSF0G77WjhAcSint8UolYeOdOuOl+EfSGoFYRpUFHRToqvctQf6lg64/61OxkZ+LzzI6IfsX3/aTOws9PaEZVr4EC0Fqj3Lpxtgi;\n\t25:ANFl/na3k8dR+wO7NrhoUkXgrrlwYCU0g08fbKmsNqXEaETo+fiokfvNLTZKPs6im17xBUPHXQs77bmaUvQX61imD2I/beUryPe7oLZBfY6uWwqdI3WtMoEZiAeNimqh9KQ6mvFACIhgjaLRrnTYs/x4hkLTcF1KYfM+g/TgJ++qSAdWeMVTHzrhmOgxBPII7IghcF0BaEFdRt8PSiuUuqe7fUL8xoly+m6oWMROrYj+4HguVPJFIxyczgsOvtlzxmljdcm/Z8f6HzECafbvY9R2vZJZ0+1CFrcVc7PhzzDd/o8IAhITsaL2c+K+edmAq8HRqYCNlsbBKN0Umo3zeQ==;\n\t31:TWMl9HZSY7nHI4CWFnGrvPjD71AT9Q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ZajuTTI9beLoqM1pL9ZyjheAmP+5gaEZGKDhtHdTw65HJvgSX58U2wzdzlA4szENr2//9WVxF7W+D6LqXZXfz83ZOj4=;\n\t7:Hzf27g4ha9ghkxxqj+gJ9S1jRFMeo33P8MTeLw6X68uafUQkE8g3s52A0QbOwpjKPGaHdFyV9hDLpZg0jri8vu2xDwVU2LSMZ47prmmuQrhNcckoke8PGWsBlxKAETTuSQwiJl5miON02mXuufKNslD+mIPSpvWu+q6n84Q34jQAyO9itAvl83filmQM38NXDC/8CPVbOm2cuiv2GByBRbDmiem3VS8Z2g79n99yQ6k=","1; VI1PR0802MB2559;\n\t20:yIf706ENcNGP7TXoFXaHe1S+/iGdy0aurS4JdEXhYCdLJNbtGBxH3g/d4UcYvU9ft38kIPm0lORg/S1cT/JckB17zIQte7EErbbz6crlP3kTXIKdWw57oDCTfwcm3x/eRkdDkskhowCLlaZHZSHXeRT4yTx3jPDQrgPBpZxOqsY="],"X-MS-TrafficTypeDiagnostic":"VI1PR0802MB2559:","X-Exchange-Antispam-Report-Test":"UriScan:;","X-Microsoft-Antispam-PRVS":"<VI1PR0802MB255930B86A0C6FCA0AB79DCAAC780@VI1PR0802MB2559.eurprd08.prod.outlook.com>","X-Exchange-Antispam-Report-CFA-Test":"BCL:0; PCL:0;\n\tRULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(2401047)(8121501046)(5005006)(93006095)(93001095)(100000703101)(100105400095)(10201501046)(3002001)(6041248)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123555025)(20161123558100)(20161123564025)(20161123562025)(20161123560025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);\n\tSRVR:VI1PR0802MB2559; BCL:0; PCL:0;\n\tRULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);\n\tSRVR:VI1PR0802MB2559; ","X-Forefront-PRVS":"04433051BF","X-Forefront-Antispam-Report":"SFV:NSPM;\n\tSFS:(10019020)(6049001)(6009001)(346002)(376002)(39830400002)(377424004)(24454002)(189002)(199003)(229853002)(77096006)(83506001)(6486002)(36756003)(97736004)(53936002)(6246003)(50466002)(25786009)(8936002)(2950100002)(6666003)(86362001)(31696002)(8676002)(2906002)(107886003)(58126008)(81156014)(81166006)(16526017)(316002)(16576012)(6116002)(106356001)(7736002)(31686004)(53546010)(50986999)(33646002)(76176999)(54356999)(3846002)(189998001)(305945005)(105586002)(68736007)(101416001)(478600001)(4326008)(47776003)(23676002)(64126003)(5660300001)(66066001)(230700001)(65806001)(65956001)(65826007);\n\tDIR:OUT; SFP:1102; SCL:1; SRVR:VI1PR0802MB2559; H:[172.16.25.50];\n\tFPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; ","Received-SPF":"None (protection.outlook.com: virtuozzo.com does not designate\n\tpermitted sender hosts)","SpamDiagnosticOutput":"1:99","SpamDiagnosticMetadata":"NSPM","X-OriginatorOrg":"virtuozzo.com","X-MS-Exchange-CrossTenant-OriginalArrivalTime":"27 Sep 2017 16:28:17.2964\n\t(UTC)","X-MS-Exchange-CrossTenant-FromEntityHeader":"Hosted","X-MS-Exchange-CrossTenant-Id":"0bc7f26d-0264-416e-a6fc-8352af79c58f","X-MS-Exchange-Transport-CrossTenantHeadersStamped":"VI1PR0802MB2559","X-detected-operating-system":"by eggs.gnu.org: Windows 7 or 8 [fuzzy]","X-Received-From":"40.107.2.131","Subject":"Re: [Qemu-devel] [PATCH v2 2/2] qcow2: truncate the tail of the\n\timage file after shrinking the image","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":"kwolf@redhat.com, jsnow@redhat.com, den@openvz.org","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":1776476,"web_url":"http://patchwork.ozlabs.org/comment/1776476/","msgid":"<8cdd4df8-a9c0-70f1-909c-ba7e91ab554c@redhat.com>","list_archive_url":null,"date":"2017-09-27T16:36:26","subject":"Re: [Qemu-devel] [PATCH v2 2/2] qcow2: truncate the tail of the\n\timage file after shrinking the image","submitter":{"id":36836,"url":"http://patchwork.ozlabs.org/api/people/36836/","name":"Max Reitz","email":"mreitz@redhat.com"},"content":"On 2017-09-27 18:27, Pavel Butsykin wrote:\n> On 27.09.2017 19:00, Max Reitz wrote:\n>> On 2017-09-22 11:39, Pavel Butsykin wrote:\n>>> Now after shrinking the image, at the end of the image file, there\n>>> might be a\n>>> tail that probably will never be used. So we can find the last used\n>>> cluster and\n>>> cut the tail.\n>>>\n>>> Signed-off-by: Pavel Butsykin <pbutsykin@virtuozzo.com>\n>>> ---\n>>>   block/qcow2-refcount.c | 22 ++++++++++++++++++++++\n>>>   block/qcow2.c          | 23 +++++++++++++++++++++++\n>>>   block/qcow2.h          |  1 +\n>>>   3 files changed, 46 insertions(+)\n>>>\n>>> diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c\n>>> index 88d5a3f1ad..aa3fd6cf17 100644\n>>> --- a/block/qcow2-refcount.c\n>>> +++ b/block/qcow2-refcount.c\n>>> @@ -3181,3 +3181,25 @@ out:\n>>>       g_free(reftable_tmp);\n>>>       return ret;\n>>>   }\n>>> +\n>>> +int64_t qcow2_get_last_cluster(BlockDriverState *bs, int64_t size)\n>>> +{\n>>> +    BDRVQcow2State *s = bs->opaque;\n>>> +    int64_t i;\n>>> +\n>>> +    for (i = size_to_clusters(s, size) - 1; i >= 0; i--) {\n>>> +        uint64_t refcount;\n>>> +        int ret = qcow2_get_refcount(bs, i, &refcount);\n>>> +        if (ret < 0) {\n>>> +            fprintf(stderr, \"Can't get refcount for cluster %\"\n>>> PRId64 \": %s\\n\",\n>>> +                    i, strerror(-ret));\n>>> +            return ret;\n>>> +        }\n>>> +        if (refcount > 0) {\n>>> +            return i;\n>>> +        }\n>>> +    }\n>>> +    qcow2_signal_corruption(bs, true, -1, -1,\n>>> +                            \"There are no references in the refcount\n>>> table.\");\n>>> +    return -EIO;\n>>> +}\n>>> diff --git a/block/qcow2.c b/block/qcow2.c\n>>> index 8a4311d338..8dfb5393a7 100644\n>>> --- a/block/qcow2.c\n>>> +++ b/block/qcow2.c\n>>> @@ -3106,6 +3106,7 @@ static int qcow2_truncate(BlockDriverState *bs,\n>>> int64_t offset,\n>>>       new_l1_size = size_to_l1(s, offset);\n>>>         if (offset < old_length) {\n>>> +        int64_t last_cluster, old_file_size;\n>>>           if (prealloc != PREALLOC_MODE_OFF) {\n>>>               error_setg(errp,\n>>>                          \"Preallocation can't be used for shrinking\n>>> an image\");\n>>> @@ -3134,6 +3135,28 @@ static int qcow2_truncate(BlockDriverState\n>>> *bs, int64_t offset,\n>>>                                \"Failed to discard unused refblocks\");\n>>>               return ret;\n>>>           }\n>>> +\n>>> +        old_file_size = bdrv_getlength(bs->file->bs);\n>>> +        if (old_file_size < 0) {\n>>> +            error_setg_errno(errp, -old_file_size,\n>>> +                             \"Failed to inquire current file length\");\n>>> +            return old_file_size;\n>>> +        }\n>>> +        last_cluster = qcow2_get_last_cluster(bs, old_file_size);\n>>> +        if (last_cluster < 0) {\n>>> +            error_setg_errno(errp, -last_cluster,\n>>> +                             \"Failed to find the last cluster\");\n>>> +            return last_cluster;\n>>> +        }\n>>\n>> My idea was rather that you just wouldn't truncate the image file if\n>> something fails here.  So in any of these new cases where you currently\n>> just report the whole truncate operation as having failed, you could\n>> just emit a warning and not do the truncation of bs->file.\n> \n> I'm not sure that's right. If the qcow2_get_last_cluster() returned an\n> error, probably with the image was a problem.. can we continue to work\n> with the image without risking to damage it even more? if something bad\n> happened with the reftable we usually mark the image as corrupted, it's\n> the same thing.\n\nWell, the only thing that's left to do is to write the new size into the\nimage header, so I think that should work just fine...\n\nI won't disagree that bdrv_getlength() or qcow2_get_last_cluster()\nfailing may be reasons to stop truncation (although I don't think they\nnecessarily are at this point).\n\nBut I could well imagine that the below bdrv_truncate() of bs->file\nfails for benign reasons, e.g. because the underlying protocol does not\nsupport shrinking of images or something.  Then we probably should carry on.\n\nMax\n\n> Although if the shrink is almost complete, the truncation of bs->file\n> isn't so important thing and we could update qcow2 header.\n> \n>> I can live with the current version, though, so:\n>>\n>> Reviewed-by: Max Reitz <mreitz@redhat.com>\n>>\n>> But I'll wait for a response from you before merging this series.\n>>\n>> Max\n>>\n>>> +        if ((last_cluster + 1) * s->cluster_size < old_file_size) {\n>>> +            ret = bdrv_truncate(bs->file, (last_cluster + 1) *\n>>> s->cluster_size,\n>>> +                                PREALLOC_MODE_OFF, NULL);\n>>> +            if (ret < 0) {\n>>> +                error_setg_errno(errp, -ret,\n>>> +                                 \"Failed to truncate the tail of the\n>>> image\");\n>>> +                return ret;\n>>> +            }\n>>> +        }\n>>>       } else {\n>>>           ret = qcow2_grow_l1_table(bs, new_l1_size, true);\n>>>           if (ret < 0) {\n>>> diff --git a/block/qcow2.h b/block/qcow2.h\n>>> index 5a289a81e2..782a206ecb 100644\n>>> --- a/block/qcow2.h\n>>> +++ b/block/qcow2.h\n>>> @@ -597,6 +597,7 @@ int qcow2_change_refcount_order(BlockDriverState\n>>> *bs, int refcount_order,\n>>>                                   BlockDriverAmendStatusCB *status_cb,\n>>>                                   void *cb_opaque, Error **errp);\n>>>   int qcow2_shrink_reftable(BlockDriverState *bs);\n>>> +int64_t qcow2_get_last_cluster(BlockDriverState *bs, int64_t size);\n>>>     /* qcow2-cluster.c functions */\n>>>   int qcow2_grow_l1_table(BlockDriverState *bs, uint64_t min_size,\n>>>\n>>\n>>","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-mx07.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com","ext-mx07.extmail.prod.ext.phx2.redhat.com;\n\tspf=fail smtp.mailfrom=mreitz@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 3y2Nl6088Fz9t3B\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu, 28 Sep 2017 02:37:06 +1000 (AEST)","from localhost ([::1]:55564 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 1dxFKZ-0001cj-Jx\n\tfor incoming@patchwork.ozlabs.org; Wed, 27 Sep 2017 12:37:03 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:52739)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <mreitz@redhat.com>) id 1dxFKC-0001bU-QC\n\tfor qemu-devel@nongnu.org; Wed, 27 Sep 2017 12:36:42 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <mreitz@redhat.com>) id 1dxFKB-0001mk-Il\n\tfor qemu-devel@nongnu.org; Wed, 27 Sep 2017 12:36:40 -0400","from mx1.redhat.com ([209.132.183.28]:57466)\n\tby eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <mreitz@redhat.com>)\n\tid 1dxFK6-0001kh-BP; Wed, 27 Sep 2017 12:36:34 -0400","from smtp.corp.redhat.com\n\t(int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14])\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 33BA3C0BBF3E;\n\tWed, 27 Sep 2017 16:36:33 +0000 (UTC)","from dresden.str.redhat.com (unknown [10.40.205.58])\n\tby smtp.corp.redhat.com (Postfix) with ESMTPS id 8C7A35ED20;\n\tWed, 27 Sep 2017 16:36:28 +0000 (UTC)"],"DMARC-Filter":"OpenDMARC Filter v1.3.2 mx1.redhat.com 33BA3C0BBF3E","To":"Pavel Butsykin <pbutsykin@virtuozzo.com>, qemu-block@nongnu.org,\n\tqemu-devel@nongnu.org","References":"<20170922093926.9723-1-pbutsykin@virtuozzo.com>\n\t<20170922093926.9723-3-pbutsykin@virtuozzo.com>\n\t<46949467-5bed-602b-5d64-badf92c059e1@redhat.com>\n\t<6a53fa30-03b0-cd04-ef12-e41656e78900@virtuozzo.com>","From":"Max Reitz <mreitz@redhat.com>","Message-ID":"<8cdd4df8-a9c0-70f1-909c-ba7e91ab554c@redhat.com>","Date":"Wed, 27 Sep 2017 18:36:26 +0200","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":"<6a53fa30-03b0-cd04-ef12-e41656e78900@virtuozzo.com>","Content-Type":"multipart/signed; micalg=pgp-sha256;\n\tprotocol=\"application/pgp-signature\";\n\tboundary=\"5Vopc6NxQjKWEwukvwH3mcKV3IScMoPMG\"","X-Scanned-By":"MIMEDefang 2.79 on 10.5.11.14","X-Greylist":"Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.31]);\n\tWed, 27 Sep 2017 16:36:33 +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 v2 2/2] qcow2: truncate the tail of the\n\timage file after shrinking the image","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":"kwolf@redhat.com, jsnow@redhat.com, den@openvz.org","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":1776888,"web_url":"http://patchwork.ozlabs.org/comment/1776888/","msgid":"<d5639553-62be-ad3d-c8f2-4cde4a2a0957@virtuozzo.com>","list_archive_url":null,"date":"2017-09-28T08:57:07","subject":"Re: [Qemu-devel] [PATCH v2 2/2] qcow2: truncate the tail of the\n\timage file after shrinking the image","submitter":{"id":67271,"url":"http://patchwork.ozlabs.org/api/people/67271/","name":"Pavel Butsykin","email":"pbutsykin@virtuozzo.com"},"content":"On 27.09.2017 19:36, Max Reitz wrote:\n> On 2017-09-27 18:27, Pavel Butsykin wrote:\n>> On 27.09.2017 19:00, Max Reitz wrote:\n>>> On 2017-09-22 11:39, Pavel Butsykin wrote:\n>>>> Now after shrinking the image, at the end of the image file, there\n>>>> might be a\n>>>> tail that probably will never be used. So we can find the last used\n>>>> cluster and\n>>>> cut the tail.\n>>>>\n>>>> Signed-off-by: Pavel Butsykin <pbutsykin@virtuozzo.com>\n>>>> ---\n>>>>    block/qcow2-refcount.c | 22 ++++++++++++++++++++++\n>>>>    block/qcow2.c          | 23 +++++++++++++++++++++++\n>>>>    block/qcow2.h          |  1 +\n>>>>    3 files changed, 46 insertions(+)\n>>>>\n>>>> diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c\n>>>> index 88d5a3f1ad..aa3fd6cf17 100644\n>>>> --- a/block/qcow2-refcount.c\n>>>> +++ b/block/qcow2-refcount.c\n>>>> @@ -3181,3 +3181,25 @@ out:\n>>>>        g_free(reftable_tmp);\n>>>>        return ret;\n>>>>    }\n>>>> +\n>>>> +int64_t qcow2_get_last_cluster(BlockDriverState *bs, int64_t size)\n>>>> +{\n>>>> +    BDRVQcow2State *s = bs->opaque;\n>>>> +    int64_t i;\n>>>> +\n>>>> +    for (i = size_to_clusters(s, size) - 1; i >= 0; i--) {\n>>>> +        uint64_t refcount;\n>>>> +        int ret = qcow2_get_refcount(bs, i, &refcount);\n>>>> +        if (ret < 0) {\n>>>> +            fprintf(stderr, \"Can't get refcount for cluster %\"\n>>>> PRId64 \": %s\\n\",\n>>>> +                    i, strerror(-ret));\n>>>> +            return ret;\n>>>> +        }\n>>>> +        if (refcount > 0) {\n>>>> +            return i;\n>>>> +        }\n>>>> +    }\n>>>> +    qcow2_signal_corruption(bs, true, -1, -1,\n>>>> +                            \"There are no references in the refcount\n>>>> table.\");\n>>>> +    return -EIO;\n>>>> +}\n>>>> diff --git a/block/qcow2.c b/block/qcow2.c\n>>>> index 8a4311d338..8dfb5393a7 100644\n>>>> --- a/block/qcow2.c\n>>>> +++ b/block/qcow2.c\n>>>> @@ -3106,6 +3106,7 @@ static int qcow2_truncate(BlockDriverState *bs,\n>>>> int64_t offset,\n>>>>        new_l1_size = size_to_l1(s, offset);\n>>>>          if (offset < old_length) {\n>>>> +        int64_t last_cluster, old_file_size;\n>>>>            if (prealloc != PREALLOC_MODE_OFF) {\n>>>>                error_setg(errp,\n>>>>                           \"Preallocation can't be used for shrinking\n>>>> an image\");\n>>>> @@ -3134,6 +3135,28 @@ static int qcow2_truncate(BlockDriverState\n>>>> *bs, int64_t offset,\n>>>>                                 \"Failed to discard unused refblocks\");\n>>>>                return ret;\n>>>>            }\n>>>> +\n>>>> +        old_file_size = bdrv_getlength(bs->file->bs);\n>>>> +        if (old_file_size < 0) {\n>>>> +            error_setg_errno(errp, -old_file_size,\n>>>> +                             \"Failed to inquire current file length\");\n>>>> +            return old_file_size;\n>>>> +        }\n>>>> +        last_cluster = qcow2_get_last_cluster(bs, old_file_size);\n>>>> +        if (last_cluster < 0) {\n>>>> +            error_setg_errno(errp, -last_cluster,\n>>>> +                             \"Failed to find the last cluster\");\n>>>> +            return last_cluster;\n>>>> +        }\n>>>\n>>> My idea was rather that you just wouldn't truncate the image file if\n>>> something fails here.  So in any of these new cases where you currently\n>>> just report the whole truncate operation as having failed, you could\n>>> just emit a warning and not do the truncation of bs->file.\n>>\n>> I'm not sure that's right. If the qcow2_get_last_cluster() returned an\n>> error, probably with the image was a problem.. can we continue to work\n>> with the image without risking to damage it even more? if something bad\n>> happened with the reftable we usually mark the image as corrupted, it's\n>> the same thing.\n> \n> Well, the only thing that's left to do is to write the new size into the\n> image header, so I think that should work just fine...\n\nYes, but what difference will update the size in the header or not, if\nthe reftable was corrupted. A much more important point here is that the\nqcow2_truncate() should return an error and the caller must stop the\nwork.\n\n> I won't disagree that bdrv_getlength() or qcow2_get_last_cluster()\n> failing may be reasons to stop truncation (although I don't think they\n> necessarily are at this point).\n> \n> But I could well imagine that the below bdrv_truncate() of bs->file\n> fails for benign reasons, e.g. because the underlying protocol does not\n> support shrinking of images or something.  Then we probably should carry on.\n\nYes, I agree here. If the bdrv_truncate() of bs->file failed, we can\nprint just a warning :) So, I'll send new version of the patch with\nthis change.\n\n> Max\n> \n>> Although if the shrink is almost complete, the truncation of bs->file\n>> isn't so important thing and we could update qcow2 header.\n>>\n>>> I can live with the current version, though, so:\n>>>\n>>> Reviewed-by: Max Reitz <mreitz@redhat.com>\n>>>\n>>> But I'll wait for a response from you before merging this series.\n>>>\n>>> Max\n>>>\n>>>> +        if ((last_cluster + 1) * s->cluster_size < old_file_size) {\n>>>> +            ret = bdrv_truncate(bs->file, (last_cluster + 1) *\n>>>> s->cluster_size,\n>>>> +                                PREALLOC_MODE_OFF, NULL);\n>>>> +            if (ret < 0) {\n>>>> +                error_setg_errno(errp, -ret,\n>>>> +                                 \"Failed to truncate the tail of the\n>>>> image\");\n>>>> +                return ret;\n>>>> +            }\n>>>> +        }\n>>>>        } else {\n>>>>            ret = qcow2_grow_l1_table(bs, new_l1_size, true);\n>>>>            if (ret < 0) {\n>>>> diff --git a/block/qcow2.h b/block/qcow2.h\n>>>> index 5a289a81e2..782a206ecb 100644\n>>>> --- a/block/qcow2.h\n>>>> +++ b/block/qcow2.h\n>>>> @@ -597,6 +597,7 @@ int qcow2_change_refcount_order(BlockDriverState\n>>>> *bs, int refcount_order,\n>>>>                                    BlockDriverAmendStatusCB *status_cb,\n>>>>                                    void *cb_opaque, Error **errp);\n>>>>    int qcow2_shrink_reftable(BlockDriverState *bs);\n>>>> +int64_t qcow2_get_last_cluster(BlockDriverState *bs, int64_t size);\n>>>>      /* qcow2-cluster.c functions */\n>>>>    int qcow2_grow_l1_table(BlockDriverState *bs, uint64_t min_size,\n>>>>\n>>>\n>>>\n> \n>","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>)","ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=virtuozzo.com header.i=@virtuozzo.com\n\theader.b=\"flHUaVw6\"; dkim-atps=neutral","spf=none (sender IP is )\n\tsmtp.mailfrom=pbutsykin@virtuozzo.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 3y2pW12TNkz9t2l\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu, 28 Sep 2017 18:58:04 +1000 (AEST)","from localhost ([::1]:58041 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 1dxUds-00046V-R3\n\tfor incoming@patchwork.ozlabs.org; Thu, 28 Sep 2017 04:58:00 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:55609)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <pbutsykin@virtuozzo.com>) id 1dxUdV-000466-Ma\n\tfor qemu-devel@nongnu.org; Thu, 28 Sep 2017 04:57:39 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <pbutsykin@virtuozzo.com>) id 1dxUdP-0004c9-4i\n\tfor qemu-devel@nongnu.org; Thu, 28 Sep 2017 04:57:37 -0400","from mail-ve1eur01on0123.outbound.protection.outlook.com\n\t([104.47.1.123]:8271\n\thelo=EUR01-VE1-obe.outbound.protection.outlook.com)\n\tby eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <pbutsykin@virtuozzo.com>)\n\tid 1dxUdO-0004am-AA; Thu, 28 Sep 2017 04:57:31 -0400","from [172.16.25.50] (195.214.232.6) by\n\tVI1PR0802MB2559.eurprd08.prod.outlook.com (2603:10a6:800:ae::9) with\n\tMicrosoft SMTP Server (version=TLS1_2,\n\tcipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.77.7;\n\tThu, 28 Sep 2017 08:57:26 +0000"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com;\n\ts=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version;\n\tbh=/EZwFAT2Jn1FTUWf8cRztNr2kEx5q+nTLxmjpajVPCM=;\n\tb=flHUaVw6PTLQmqWQZAdS+yzdz0Tx0CQtZmsc4B1EYdybL9hBftz6rdbj2qa32/dm0TfWqYzBqgGC+ivUk+aO2PNGakkpmRJWuCxRN5L00Khy2kaoA+bDXNzyeN66L1J37khT5X1+osLZ27cOf3UEqnA0jalGgrU4zaI2Yb5XT3s=","To":"Max Reitz <mreitz@redhat.com>, qemu-block@nongnu.org,\n\tqemu-devel@nongnu.org","References":"<20170922093926.9723-1-pbutsykin@virtuozzo.com>\n\t<20170922093926.9723-3-pbutsykin@virtuozzo.com>\n\t<46949467-5bed-602b-5d64-badf92c059e1@redhat.com>\n\t<6a53fa30-03b0-cd04-ef12-e41656e78900@virtuozzo.com>\n\t<8cdd4df8-a9c0-70f1-909c-ba7e91ab554c@redhat.com>","From":"Pavel Butsykin <pbutsykin@virtuozzo.com>","Message-ID":"<d5639553-62be-ad3d-c8f2-4cde4a2a0957@virtuozzo.com>","Date":"Thu, 28 Sep 2017 11:57:07 +0300","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101\n\tThunderbird/52.2.1","MIME-Version":"1.0","In-Reply-To":"<8cdd4df8-a9c0-70f1-909c-ba7e91ab554c@redhat.com>","Content-Type":"text/plain; charset=utf-8; format=flowed","Content-Language":"en-US","Content-Transfer-Encoding":"7bit","X-Originating-IP":"[195.214.232.6]","X-ClientProxiedBy":"AM5PR0402CA0018.eurprd04.prod.outlook.com\n\t(2603:10a6:203:90::28) To VI1PR0802MB2559.eurprd08.prod.outlook.com\n\t(2603:10a6:800:ae::9)","X-MS-PublicTrafficType":"Email","X-MS-Office365-Filtering-Correlation-Id":"6b812bac-152d-4442-fa65-08d5064ef1cb","X-Microsoft-Antispam":"UriScan:; BCL:0; PCL:0;\n\tRULEID:(22001)(2017030254152)(2017052603199)(201703131423075)(201703031133081)(201702281549075);\n\tSRVR:VI1PR0802MB2559; ","X-Microsoft-Exchange-Diagnostics":["1; VI1PR0802MB2559;\n\t3:RdKR5nErYspPU12sLXOBRhobkwM2MMBh8eu60CXwOu4TlXfArHcPlGnmJYBbLYAfsknA1j0rp9iiHWHlaujWIOMUueMsaoAtgG/4oxl7w4jm4gbRbg3qqgvJA62K3dkDbm178YL6LoXE1EQyZSvyELWXRHb07vUveA88m5G1MwrDrbGXI25z4GGNBhSq3Zh5kDgbJ9PE9/Nskmy/9SZGRxofa2Sl5PS87PNpBapYTs3NBWopeSsuHqZ0GN4OuDfO;\n\t25:14nOih7j7FBpZJEfw4xPOkN/4tsQjyT4FA7rzmjp7I206+E32P56EHB6LEYnw2+xITlz6h1QXIY5sz8PsD2XCd3aI7/5cWxx7V15QbTolfqQ+UsYEymubJjULsbxtlN9I7Ke27d2hoNRceGWOPfT699ZM/CX0+deB0vqhwuA0Sfr1vkUZpidhQYRPFgduUYK1xUHnFCgoVkbEzQ0tpJTCQRp90FMoO7wHl6tvItrs57xB4aGM/wWctIwiqehu+b0KGERhtplsc8yRdytp8vGNh1Fdp+FiEKam+MPoT9oqDzZj49T8lG1LJuWcwDWXbA2EYQALHNS2ezm0rto6HyWEQ==;\n\t31:hMkM32vs+eOtV8GBHXWJZXf72crK7ov87sDHre5VA3m2Wd5CruFNnf6h1xzO+4GBVK77Nybj7HtUvDlTqsyrRT0OrHjG8XWKjMUqOQPP4GtaIoG0njMU5frmBJi6gfqAWeRADJPT5u/FmB0282/afmPjJJug7JuS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mIq3oxSouh8Teai7Oj2XV9dWT9c=;\n\t7:rxfcwWhZVxO4Sq1lcI5nOIoR/lsaKqd/5oJ1zLc13bgLyccvCaMJi6kiEr3Rcp4Sh/zBH8Dcv7lrWCsmilODg9k2Fr3UrqyEmD9A1nF3R2kv5JHy4lUgrBvtDg9bzXEmAwLV5Gt7AEN4ozhwTNfPW8k82bNBBva9seqpElguxgx8ElUm+PTcLo5XmIdp62LUNMvcX+kGA30Y+I4fzHhPpQCwg2JS7ts2pdMLFAM1Bwo=","1; VI1PR0802MB2559;\n\t20:u01BvR6dSCQFirbjYmKu2Vfc6HyK7q+fOBWNQ1g8pMxKDn/iskzYepIa56R5XOecMC2IhPqDj7Epmy3ILzuW0M3QVo/CFLHHEkrVq0sE23Maj/F0vZ1us428xd5NFfFZ8FBO4O0MIAH2aRkarZ54oAhnsMJYh9+hBwuuqcd76o0="],"X-MS-TrafficTypeDiagnostic":"VI1PR0802MB2559:","X-Exchange-Antispam-Report-Test":"UriScan:;","X-Microsoft-Antispam-PRVS":"<VI1PR0802MB2559B926D838A17EDE71EAA2AC790@VI1PR0802MB2559.eurprd08.prod.outlook.com>","X-Exchange-Antispam-Report-CFA-Test":"BCL:0; PCL:0;\n\tRULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(2401047)(5005006)(8121501046)(10201501046)(3002001)(100000703101)(100105400095)(93006095)(93001095)(6041248)(20161123564025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123562025)(20161123560025)(20161123555025)(20161123558100)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);\n\tSRVR:VI1PR0802MB2559; BCL:0; PCL:0;\n\tRULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);\n\tSRVR:VI1PR0802MB2559; ","X-Forefront-PRVS":"0444EB1997","X-Forefront-Antispam-Report":"SFV:NSPM;\n\tSFS:(10019020)(6049001)(6009001)(376002)(346002)(377424004)(24454002)(51444003)(199003)(189002)(2950100002)(6666003)(229853002)(83506001)(6486002)(97736004)(25786009)(77096006)(36756003)(53936002)(50466002)(6246003)(8936002)(31696002)(2906002)(8676002)(93886005)(58126008)(16576012)(107886003)(81166006)(16526017)(316002)(86362001)(81156014)(6116002)(7736002)(106356001)(31686004)(53546010)(50986999)(3846002)(76176999)(33646002)(54356999)(305945005)(105586002)(189998001)(101416001)(68736007)(4326008)(478600001)(64126003)(23676002)(47776003)(230700001)(65956001)(5660300001)(66066001)(65806001)(65826007);\n\tDIR:OUT; SFP:1102; SCL:1; SRVR:VI1PR0802MB2559; H:[172.16.25.50];\n\tFPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; ","Received-SPF":"None (protection.outlook.com: virtuozzo.com does not designate\n\tpermitted sender hosts)","SpamDiagnosticOutput":"1:99","SpamDiagnosticMetadata":"NSPM","X-OriginatorOrg":"virtuozzo.com","X-MS-Exchange-CrossTenant-OriginalArrivalTime":"28 Sep 2017 08:57:26.9029\n\t(UTC)","X-MS-Exchange-CrossTenant-FromEntityHeader":"Hosted","X-MS-Exchange-CrossTenant-Id":"0bc7f26d-0264-416e-a6fc-8352af79c58f","X-MS-Exchange-Transport-CrossTenantHeadersStamped":"VI1PR0802MB2559","X-detected-operating-system":"by eggs.gnu.org: Windows 7 or 8 [fuzzy]","X-Received-From":"104.47.1.123","Subject":"Re: [Qemu-devel] [PATCH v2 2/2] qcow2: truncate the tail of the\n\timage file after shrinking the image","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":"kwolf@redhat.com, jsnow@redhat.com, den@openvz.org","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>"}}]