[{"id":1774798,"web_url":"http://patchwork.ozlabs.org/comment/1774798/","msgid":"<f305e22b-963e-f1eb-710c-d74c6efc9628@virtuozzo.com>","list_archive_url":null,"date":"2017-09-25T15:23:14","subject":"Re: [Qemu-devel] [PATCH v10 05/20] dirty-bitmap: Avoid size query\n\tfailure during truncate","submitter":{"id":66592,"url":"http://patchwork.ozlabs.org/api/people/66592/","name":"Vladimir Sementsov-Ogievskiy","email":"vsementsov@virtuozzo.com"},"content":"25.09.2017 17:55, Eric Blake wrote:\n> We've previously fixed several places where we failed to account\n> for possible errors from bdrv_nb_sectors().  Fix another one by\n> making bdrv_dirty_bitmap_truncate() take the new size from the\n> caller instead of querying itself; then adjust the sole caller\n> bdrv_truncate() to pass the size just determined by a successful\n> resize, or to skip the bitmap resize on failure, thus avoiding\n\nnothing is skipped in this version\n\n> sizing the bitmaps to -1.  This also fixes a bug where not all\n> failure paths in bdrv_truncate() would set errp.\n>\n> Note that bdrv_truncate() is still a bit awkward.  We may want\n> to revisit it later and clean up things to better guarantee that\n> a resize attempt either fails cleanly up front, or cannot fail\n> after guest-visible changes have been made (if temporary changes\n> are made, then they need to be cleanly rolled back).  But that\n> is a task for another day; for now, the goal is the bare minimum\n> fix to ensure that just bdrv_dirty_bitmap_truncate() cannot fail.\n>\n> Signed-off-by: Eric Blake <eblake@redhat.com>\n\nReviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>\n\n\n\n>\n> ---\n> v10: always resize bitmap as before [John], enhance commit message to\n> point out errp bugfix [Vladimir]\n> v9: skip only bdrv_dirty_bitmap_truncate on error [Fam]\n> v8: retitle and rework to avoid possibility of secondary failure [John]\n> v7: new patch [Kevin]\n> ---\n>   include/block/dirty-bitmap.h |  2 +-\n>   block.c                      | 16 +++++++++++-----\n>   block/dirty-bitmap.c         |  6 +++---\n>   3 files changed, 15 insertions(+), 9 deletions(-)\n>\n> diff --git a/include/block/dirty-bitmap.h b/include/block/dirty-bitmap.h\n> index 8fd842eac9..7a27590047 100644\n> --- a/include/block/dirty-bitmap.h\n> +++ b/include/block/dirty-bitmap.h\n> @@ -83,7 +83,7 @@ int64_t bdrv_dirty_iter_next(BdrvDirtyBitmapIter *iter);\n>   void bdrv_set_dirty_iter(BdrvDirtyBitmapIter *hbi, int64_t sector_num);\n>   int64_t bdrv_get_dirty_count(BdrvDirtyBitmap *bitmap);\n>   int64_t bdrv_get_meta_dirty_count(BdrvDirtyBitmap *bitmap);\n> -void bdrv_dirty_bitmap_truncate(BlockDriverState *bs);\n> +void bdrv_dirty_bitmap_truncate(BlockDriverState *bs, int64_t bytes);\n>   bool bdrv_dirty_bitmap_readonly(const BdrvDirtyBitmap *bitmap);\n>   bool bdrv_has_readonly_bitmaps(BlockDriverState *bs);\n>   bool bdrv_dirty_bitmap_get_autoload(const BdrvDirtyBitmap *bitmap);\n> diff --git a/block.c b/block.c\n> index 528cda7b2c..ef5af81f66 100644\n> --- a/block.c\n> +++ b/block.c\n> @@ -3545,12 +3545,18 @@ int bdrv_truncate(BdrvChild *child, int64_t offset, PreallocMode prealloc,\n>       assert(!(bs->open_flags & BDRV_O_INACTIVE));\n>\n>       ret = drv->bdrv_truncate(bs, offset, prealloc, errp);\n> -    if (ret == 0) {\n> -        ret = refresh_total_sectors(bs, offset >> BDRV_SECTOR_BITS);\n> -        bdrv_dirty_bitmap_truncate(bs);\n> -        bdrv_parent_cb_resize(bs);\n> -        atomic_inc(&bs->write_gen);\n> +    if (ret < 0) {\n> +        return ret;\n>       }\n> +    ret = refresh_total_sectors(bs, offset >> BDRV_SECTOR_BITS);\n> +    if (ret < 0) {\n> +        error_setg_errno(errp, -ret, \"Could not refresh total sector count\");\n> +    } else {\n> +        offset = bs->total_sectors * BDRV_SECTOR_SIZE;\n> +    }\n> +    bdrv_dirty_bitmap_truncate(bs, offset);\n> +    bdrv_parent_cb_resize(bs);\n> +    atomic_inc(&bs->write_gen);\n>       return ret;\n>   }\n>\n> diff --git a/block/dirty-bitmap.c b/block/dirty-bitmap.c\n> index 42a55e4a4b..ee164fb518 100644\n> --- a/block/dirty-bitmap.c\n> +++ b/block/dirty-bitmap.c\n> @@ -1,7 +1,7 @@\n>   /*\n>    * Block Dirty Bitmap\n>    *\n> - * Copyright (c) 2016 Red Hat. Inc\n> + * Copyright (c) 2016-2017 Red Hat. Inc\n>    *\n>    * Permission is hereby granted, free of charge, to any person obtaining a copy\n>    * of this software and associated documentation files (the \"Software\"), to deal\n> @@ -302,10 +302,10 @@ BdrvDirtyBitmap *bdrv_reclaim_dirty_bitmap(BlockDriverState *bs,\n>    * Truncates _all_ bitmaps attached to a BDS.\n>    * Called with BQL taken.\n>    */\n> -void bdrv_dirty_bitmap_truncate(BlockDriverState *bs)\n> +void bdrv_dirty_bitmap_truncate(BlockDriverState *bs, int64_t bytes)\n>   {\n>       BdrvDirtyBitmap *bitmap;\n> -    uint64_t size = bdrv_nb_sectors(bs);\n> +    int64_t size = DIV_ROUND_UP(bytes, BDRV_SECTOR_SIZE);\n>\n>       bdrv_dirty_bitmaps_lock(bs);\n>       QLIST_FOREACH(bitmap, &bs->dirty_bitmaps, list) {","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>)","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 3y17Ck0mb8z9t67\n\tfor <incoming@patchwork.ozlabs.org>;\n\tTue, 26 Sep 2017 01:24:00 +1000 (AEST)","from localhost ([::1]:43019 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 1dwVEk-000436-Cj\n\tfor incoming@patchwork.ozlabs.org; Mon, 25 Sep 2017 11:23:58 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:37419)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <vsementsov@virtuozzo.com>) id 1dwVEC-00040d-NZ\n\tfor qemu-devel@nongnu.org; Mon, 25 Sep 2017 11:23:25 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <vsementsov@virtuozzo.com>) id 1dwVE9-0006zu-Es\n\tfor qemu-devel@nongnu.org; Mon, 25 Sep 2017 11:23:24 -0400","from mailhub.sw.ru ([195.214.232.25]:24585 helo=relay.sw.ru)\n\tby eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <vsementsov@virtuozzo.com>)\n\tid 1dwVE9-0006zB-29\n\tfor qemu-devel@nongnu.org; Mon, 25 Sep 2017 11:23:21 -0400","from [172.16.24.243] (msk-vpn.virtuozzo.com [195.214.232.6])\n\tby relay.sw.ru (8.13.4/8.13.4) with ESMTP id v8PFNEIb030659;\n\tMon, 25 Sep 2017 18:23:14 +0300 (MSK)"],"To":"Eric Blake <eblake@redhat.com>, qemu-devel@nongnu.org","References":"<20170925145526.32690-1-eblake@redhat.com>\n\t<20170925145526.32690-6-eblake@redhat.com>","From":"Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>","Message-ID":"<f305e22b-963e-f1eb-710c-d74c6efc9628@virtuozzo.com>","Date":"Mon, 25 Sep 2017 18:23:14 +0300","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":"<20170925145526.32690-6-eblake@redhat.com>","Content-Type":"text/plain; charset=utf-8; format=flowed","Content-Transfer-Encoding":"7bit","Content-Language":"en-US","X-detected-operating-system":"by eggs.gnu.org: OpenBSD 3.x [fuzzy]","X-Received-From":"195.214.232.25","Subject":"Re: [Qemu-devel] [PATCH v10 05/20] dirty-bitmap: Avoid size query\n\tfailure during truncate","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, famz@redhat.com, jsnow@redhat.com,\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":1774816,"web_url":"http://patchwork.ozlabs.org/comment/1774816/","msgid":"<b10bd108-0387-34eb-9aa4-7c5e3f9f63a1@redhat.com>","list_archive_url":null,"date":"2017-09-25T15:46:05","subject":"Re: [Qemu-devel] [PATCH v10 05/20] dirty-bitmap: Avoid size query\n\tfailure during truncate","submitter":{"id":6591,"url":"http://patchwork.ozlabs.org/api/people/6591/","name":"Eric Blake","email":"eblake@redhat.com"},"content":"On 09/25/2017 10:23 AM, Vladimir Sementsov-Ogievskiy wrote:\n> 25.09.2017 17:55, Eric Blake wrote:\n>> We've previously fixed several places where we failed to account\n>> for possible errors from bdrv_nb_sectors().  Fix another one by\n>> making bdrv_dirty_bitmap_truncate() take the new size from the\n>> caller instead of querying itself; then adjust the sole caller\n>> bdrv_truncate() to pass the size just determined by a successful\n>> resize, or to skip the bitmap resize on failure, thus avoiding\n> \n> nothing is skipped in this version\n\nSo much for me squashing in a change.  If the maintainer is willing\n(Kevin, is this going through your tree?), we can reword that to:\n\n\"...pass the size just determined by a successful resize, or to reuse\nthe size given to the original truncate operation when\nrefresh_total_sectors() was not able to confirm the actual size (the two\nsizes can potentially differ according to rounding constraints), thus\navoiding...\"\n\n> \n>> sizing the bitmaps to -1.  This also fixes a bug where not all\n>> failure paths in bdrv_truncate() would set errp.\n>>\n>> Note that bdrv_truncate() is still a bit awkward.  We may want\n>> to revisit it later and clean up things to better guarantee that\n>> a resize attempt either fails cleanly up front, or cannot fail\n>> after guest-visible changes have been made (if temporary changes\n>> are made, then they need to be cleanly rolled back).  But that\n>> is a task for another day; for now, the goal is the bare minimum\n>> fix to ensure that just bdrv_dirty_bitmap_truncate() cannot fail.\n>>\n>> Signed-off-by: Eric Blake <eblake@redhat.com>\n> \n> Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>\n> \n> \n> \n>>\n>> ---\n>> v10: always resize bitmap as before [John], enhance commit message to\n>> point out errp bugfix [Vladimir]\n>> v9: skip only bdrv_dirty_bitmap_truncate on error [Fam]\n>> v8: retitle and rework to avoid possibility of secondary failure [John]\n>> v7: new patch [Kevin]\n>> ---\n>>   include/block/dirty-bitmap.h |  2 +-\n>>   block.c                      | 16 +++++++++++-----\n>>   block/dirty-bitmap.c         |  6 +++---\n>>   3 files changed, 15 insertions(+), 9 deletions(-)\n>>\n>> diff --git a/include/block/dirty-bitmap.h b/include/block/dirty-bitmap.h\n>> index 8fd842eac9..7a27590047 100644\n>> --- a/include/block/dirty-bitmap.h\n>> +++ b/include/block/dirty-bitmap.h\n>> @@ -83,7 +83,7 @@ int64_t bdrv_dirty_iter_next(BdrvDirtyBitmapIter\n>> *iter);\n>>   void bdrv_set_dirty_iter(BdrvDirtyBitmapIter *hbi, int64_t sector_num);\n>>   int64_t bdrv_get_dirty_count(BdrvDirtyBitmap *bitmap);\n>>   int64_t bdrv_get_meta_dirty_count(BdrvDirtyBitmap *bitmap);\n>> -void bdrv_dirty_bitmap_truncate(BlockDriverState *bs);\n>> +void bdrv_dirty_bitmap_truncate(BlockDriverState *bs, int64_t bytes);\n>>   bool bdrv_dirty_bitmap_readonly(const BdrvDirtyBitmap *bitmap);\n>>   bool bdrv_has_readonly_bitmaps(BlockDriverState *bs);\n>>   bool bdrv_dirty_bitmap_get_autoload(const BdrvDirtyBitmap *bitmap);\n>> diff --git a/block.c b/block.c\n>> index 528cda7b2c..ef5af81f66 100644\n>> --- a/block.c\n>> +++ b/block.c\n>> @@ -3545,12 +3545,18 @@ int bdrv_truncate(BdrvChild *child, int64_t\n>> offset, PreallocMode prealloc,\n>>       assert(!(bs->open_flags & BDRV_O_INACTIVE));\n>>\n>>       ret = drv->bdrv_truncate(bs, offset, prealloc, errp);\n>> -    if (ret == 0) {\n>> -        ret = refresh_total_sectors(bs, offset >> BDRV_SECTOR_BITS);\n>> -        bdrv_dirty_bitmap_truncate(bs);\n>> -        bdrv_parent_cb_resize(bs);\n>> -        atomic_inc(&bs->write_gen);\n>> +    if (ret < 0) {\n>> +        return ret;\n>>       }\n>> +    ret = refresh_total_sectors(bs, offset >> BDRV_SECTOR_BITS);\n>> +    if (ret < 0) {\n>> +        error_setg_errno(errp, -ret, \"Could not refresh total sector\n>> count\");\n>> +    } else {\n>> +        offset = bs->total_sectors * BDRV_SECTOR_SIZE;\n>> +    }\n>> +    bdrv_dirty_bitmap_truncate(bs, offset);\n>> +    bdrv_parent_cb_resize(bs);\n>> +    atomic_inc(&bs->write_gen);\n>>       return ret;\n>>   }\n>>\n>> diff --git a/block/dirty-bitmap.c b/block/dirty-bitmap.c\n>> index 42a55e4a4b..ee164fb518 100644\n>> --- a/block/dirty-bitmap.c\n>> +++ b/block/dirty-bitmap.c\n>> @@ -1,7 +1,7 @@\n>>   /*\n>>    * Block Dirty Bitmap\n>>    *\n>> - * Copyright (c) 2016 Red Hat. Inc\n>> + * Copyright (c) 2016-2017 Red Hat. Inc\n>>    *\n>>    * Permission is hereby granted, free of charge, to any person\n>> obtaining a copy\n>>    * of this software and associated documentation files (the\n>> \"Software\"), to deal\n>> @@ -302,10 +302,10 @@ BdrvDirtyBitmap\n>> *bdrv_reclaim_dirty_bitmap(BlockDriverState *bs,\n>>    * Truncates _all_ bitmaps attached to a BDS.\n>>    * Called with BQL taken.\n>>    */\n>> -void bdrv_dirty_bitmap_truncate(BlockDriverState *bs)\n>> +void bdrv_dirty_bitmap_truncate(BlockDriverState *bs, int64_t bytes)\n>>   {\n>>       BdrvDirtyBitmap *bitmap;\n>> -    uint64_t size = bdrv_nb_sectors(bs);\n>> +    int64_t size = DIV_ROUND_UP(bytes, BDRV_SECTOR_SIZE);\n>>\n>>       bdrv_dirty_bitmaps_lock(bs);\n>>       QLIST_FOREACH(bitmap, &bs->dirty_bitmaps, list) {\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-mx06.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com","ext-mx06.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 3y17kV3h78z9tXC\n\tfor <incoming@patchwork.ozlabs.org>;\n\tTue, 26 Sep 2017 01:47:13 +1000 (AEST)","from localhost ([::1]:43114 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 1dwVbB-0006ua-2u\n\tfor incoming@patchwork.ozlabs.org; Mon, 25 Sep 2017 11:47:09 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:43034)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <eblake@redhat.com>) id 1dwVal-0006sk-La\n\tfor qemu-devel@nongnu.org; Mon, 25 Sep 2017 11:46:45 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <eblake@redhat.com>) id 1dwVak-00007N-AG\n\tfor qemu-devel@nongnu.org; Mon, 25 Sep 2017 11:46:43 -0400","from mx1.redhat.com ([209.132.183.28]:45938)\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 1dwVae-0008VI-5Z; Mon, 25 Sep 2017 11:46: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 08B0520B17;\n\tMon, 25 Sep 2017 15:46:35 +0000 (UTC)","from [10.10.124.97] (ovpn-124-97.rdu2.redhat.com [10.10.124.97])\n\tby smtp.corp.redhat.com (Postfix) with ESMTP id 36F8567C84;\n\tMon, 25 Sep 2017 15:46:06 +0000 (UTC)"],"DMARC-Filter":"OpenDMARC Filter v1.3.2 mx1.redhat.com 08B0520B17","To":"Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>,\n\tqemu-devel@nongnu.org","References":"<20170925145526.32690-1-eblake@redhat.com>\n\t<20170925145526.32690-6-eblake@redhat.com>\n\t<f305e22b-963e-f1eb-710c-d74c6efc9628@virtuozzo.com>","From":"Eric Blake <eblake@redhat.com>","Openpgp":"url=http://people.redhat.com/eblake/eblake.gpg","Organization":"Red Hat, Inc.","Message-ID":"<b10bd108-0387-34eb-9aa4-7c5e3f9f63a1@redhat.com>","Date":"Mon, 25 Sep 2017 10:46:05 -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":"<f305e22b-963e-f1eb-710c-d74c6efc9628@virtuozzo.com>","Content-Type":"multipart/signed; micalg=pgp-sha256;\n\tprotocol=\"application/pgp-signature\";\n\tboundary=\"wjvSxnD0glrK8Tb1pnl773RDSi1PlPs1m\"","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.30]);\n\tMon, 25 Sep 2017 15:46: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","X-Content-Filtered-By":"Mailman/MimeDel 2.1.21","Subject":"Re: [Qemu-devel] [PATCH v10 05/20] dirty-bitmap: Avoid size query\n\tfailure during truncate","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, famz@redhat.com, jsnow@redhat.com,\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":1774973,"web_url":"http://patchwork.ozlabs.org/comment/1774973/","msgid":"<8da0f1ea-8650-550d-b804-b483563d94c3@redhat.com>","list_archive_url":null,"date":"2017-09-25T20:54:24","subject":"Re: [Qemu-devel] [PATCH v10 05/20] dirty-bitmap: Avoid size query\n\tfailure during truncate","submitter":{"id":64343,"url":"http://patchwork.ozlabs.org/api/people/64343/","name":"John Snow","email":"jsnow@redhat.com"},"content":"On 09/25/2017 10:55 AM, Eric Blake wrote:\n> We've previously fixed several places where we failed to account\n> for possible errors from bdrv_nb_sectors().  Fix another one by\n> making bdrv_dirty_bitmap_truncate() take the new size from the\n> caller instead of querying itself; then adjust the sole caller\n> bdrv_truncate() to pass the size just determined by a successful\n> resize, or to skip the bitmap resize on failure, thus avoiding\n> sizing the bitmaps to -1.  This also fixes a bug where not all\n> failure paths in bdrv_truncate() would set errp.\n> \n> Note that bdrv_truncate() is still a bit awkward.  We may want\n> to revisit it later and clean up things to better guarantee that\n> a resize attempt either fails cleanly up front, or cannot fail\n> after guest-visible changes have been made (if temporary changes\n> are made, then they need to be cleanly rolled back).  But that\n> is a task for another day; for now, the goal is the bare minimum\n> fix to ensure that just bdrv_dirty_bitmap_truncate() cannot fail.\n> \n> Signed-off-by: Eric Blake <eblake@redhat.com>\n> \n> ---\n> v10: always resize bitmap as before [John], enhance commit message to\n> point out errp bugfix [Vladimir]\n> v9: skip only bdrv_dirty_bitmap_truncate on error [Fam]\n> v8: retitle and rework to avoid possibility of secondary failure [John]\n> v7: new patch [Kevin]\n> ---\n>  include/block/dirty-bitmap.h |  2 +-\n>  block.c                      | 16 +++++++++++-----\n>  block/dirty-bitmap.c         |  6 +++---\n>  3 files changed, 15 insertions(+), 9 deletions(-)\n> \n> diff --git a/include/block/dirty-bitmap.h b/include/block/dirty-bitmap.h\n> index 8fd842eac9..7a27590047 100644\n> --- a/include/block/dirty-bitmap.h\n> +++ b/include/block/dirty-bitmap.h\n> @@ -83,7 +83,7 @@ int64_t bdrv_dirty_iter_next(BdrvDirtyBitmapIter *iter);\n>  void bdrv_set_dirty_iter(BdrvDirtyBitmapIter *hbi, int64_t sector_num);\n>  int64_t bdrv_get_dirty_count(BdrvDirtyBitmap *bitmap);\n>  int64_t bdrv_get_meta_dirty_count(BdrvDirtyBitmap *bitmap);\n> -void bdrv_dirty_bitmap_truncate(BlockDriverState *bs);\n> +void bdrv_dirty_bitmap_truncate(BlockDriverState *bs, int64_t bytes);\n>  bool bdrv_dirty_bitmap_readonly(const BdrvDirtyBitmap *bitmap);\n>  bool bdrv_has_readonly_bitmaps(BlockDriverState *bs);\n>  bool bdrv_dirty_bitmap_get_autoload(const BdrvDirtyBitmap *bitmap);\n> diff --git a/block.c b/block.c\n> index 528cda7b2c..ef5af81f66 100644\n> --- a/block.c\n> +++ b/block.c\n> @@ -3545,12 +3545,18 @@ int bdrv_truncate(BdrvChild *child, int64_t offset, PreallocMode prealloc,\n>      assert(!(bs->open_flags & BDRV_O_INACTIVE));\n> \n>      ret = drv->bdrv_truncate(bs, offset, prealloc, errp);\n> -    if (ret == 0) {\n> -        ret = refresh_total_sectors(bs, offset >> BDRV_SECTOR_BITS);\n> -        bdrv_dirty_bitmap_truncate(bs);\n> -        bdrv_parent_cb_resize(bs);\n> -        atomic_inc(&bs->write_gen);\n> +    if (ret < 0) {\n> +        return ret;\n>      }\n> +    ret = refresh_total_sectors(bs, offset >> BDRV_SECTOR_BITS);\n> +    if (ret < 0) {\n> +        error_setg_errno(errp, -ret, \"Could not refresh total sector count\");\n> +    } else {\n> +        offset = bs->total_sectors * BDRV_SECTOR_SIZE;\n> +    }\n> +    bdrv_dirty_bitmap_truncate(bs, offset);\n> +    bdrv_parent_cb_resize(bs);\n> +    atomic_inc(&bs->write_gen);\n>      return ret;\n>  }\n> \n> diff --git a/block/dirty-bitmap.c b/block/dirty-bitmap.c\n> index 42a55e4a4b..ee164fb518 100644\n> --- a/block/dirty-bitmap.c\n> +++ b/block/dirty-bitmap.c\n> @@ -1,7 +1,7 @@\n>  /*\n>   * Block Dirty Bitmap\n>   *\n> - * Copyright (c) 2016 Red Hat. Inc\n> + * Copyright (c) 2016-2017 Red Hat. Inc\n>   *\n>   * Permission is hereby granted, free of charge, to any person obtaining a copy\n>   * of this software and associated documentation files (the \"Software\"), to deal\n> @@ -302,10 +302,10 @@ BdrvDirtyBitmap *bdrv_reclaim_dirty_bitmap(BlockDriverState *bs,\n>   * Truncates _all_ bitmaps attached to a BDS.\n>   * Called with BQL taken.\n>   */\n> -void bdrv_dirty_bitmap_truncate(BlockDriverState *bs)\n> +void bdrv_dirty_bitmap_truncate(BlockDriverState *bs, int64_t bytes)\n>  {\n>      BdrvDirtyBitmap *bitmap;\n> -    uint64_t size = bdrv_nb_sectors(bs);\n> +    int64_t size = DIV_ROUND_UP(bytes, BDRV_SECTOR_SIZE);\n> \n>      bdrv_dirty_bitmaps_lock(bs);\n>      QLIST_FOREACH(bitmap, &bs->dirty_bitmaps, list) {\n> \n\nI *THINK* this is the most correct we can do for now...\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-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=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 3y1GYs4Cgfz9t30\n\tfor <incoming@patchwork.ozlabs.org>;\n\tTue, 26 Sep 2017 06:55:12 +1000 (AEST)","from localhost ([::1]:44233 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 1dwaPF-0003EO-Mp\n\tfor incoming@patchwork.ozlabs.org; Mon, 25 Sep 2017 16:55:09 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:35043)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <jsnow@redhat.com>) id 1dwaOi-0003Cl-3G\n\tfor qemu-devel@nongnu.org; Mon, 25 Sep 2017 16:54:37 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <jsnow@redhat.com>) id 1dwaOg-0003sm-W3\n\tfor qemu-devel@nongnu.org; Mon, 25 Sep 2017 16:54:36 -0400","from mx1.redhat.com ([209.132.183.28]:53534)\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 1dwaOb-0003rR-ED; Mon, 25 Sep 2017 16:54:29 -0400","from smtp.corp.redhat.com\n\t(int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12])\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 30CF981F07;\n\tMon, 25 Sep 2017 20:54:28 +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 3D3366955C;\n\tMon, 25 Sep 2017 20:54:25 +0000 (UTC)"],"DMARC-Filter":"OpenDMARC Filter v1.3.2 mx1.redhat.com 30CF981F07","To":"Eric Blake <eblake@redhat.com>, qemu-devel@nongnu.org","References":"<20170925145526.32690-1-eblake@redhat.com>\n\t<20170925145526.32690-6-eblake@redhat.com>","From":"John Snow <jsnow@redhat.com>","Message-ID":"<8da0f1ea-8650-550d-b804-b483563d94c3@redhat.com>","Date":"Mon, 25 Sep 2017 16:54:24 -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":"<20170925145526.32690-6-eblake@redhat.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.12","X-Greylist":"Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.26]);\n\tMon, 25 Sep 2017 20:54:28 +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 v10 05/20] dirty-bitmap: Avoid size query\n\tfailure during truncate","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, vsementsov@virtuozzo.com, famz@redhat.com,\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":1775079,"web_url":"http://patchwork.ozlabs.org/comment/1775079/","msgid":"<20170926012538.GA31924@lemon.lan>","list_archive_url":null,"date":"2017-09-26T01:25:38","subject":"Re: [Qemu-devel] [PATCH v10 05/20] dirty-bitmap: Avoid size query\n\tfailure during truncate","submitter":{"id":24872,"url":"http://patchwork.ozlabs.org/api/people/24872/","name":"Fam Zheng","email":"famz@redhat.com"},"content":"On Mon, 09/25 09:55, Eric Blake wrote:\n> We've previously fixed several places where we failed to account\n> for possible errors from bdrv_nb_sectors().  Fix another one by\n> making bdrv_dirty_bitmap_truncate() take the new size from the\n> caller instead of querying itself; then adjust the sole caller\n> bdrv_truncate() to pass the size just determined by a successful\n> resize, or to skip the bitmap resize on failure, thus avoiding\n> sizing the bitmaps to -1.  This also fixes a bug where not all\n> failure paths in bdrv_truncate() would set errp.\n> \n> Note that bdrv_truncate() is still a bit awkward.  We may want\n> to revisit it later and clean up things to better guarantee that\n> a resize attempt either fails cleanly up front, or cannot fail\n> after guest-visible changes have been made (if temporary changes\n> are made, then they need to be cleanly rolled back).  But that\n> is a task for another day; for now, the goal is the bare minimum\n> fix to ensure that just bdrv_dirty_bitmap_truncate() cannot fail.\n> \n> Signed-off-by: Eric Blake <eblake@redhat.com>\n> \n> ---\n> v10: always resize bitmap as before [John], enhance commit message to\n> point out errp bugfix [Vladimir]\n> v9: skip only bdrv_dirty_bitmap_truncate on error [Fam]\n> v8: retitle and rework to avoid possibility of secondary failure [John]\n> v7: new patch [Kevin]\n> ---\n>  include/block/dirty-bitmap.h |  2 +-\n>  block.c                      | 16 +++++++++++-----\n>  block/dirty-bitmap.c         |  6 +++---\n>  3 files changed, 15 insertions(+), 9 deletions(-)\n> \n> diff --git a/include/block/dirty-bitmap.h b/include/block/dirty-bitmap.h\n> index 8fd842eac9..7a27590047 100644\n> --- a/include/block/dirty-bitmap.h\n> +++ b/include/block/dirty-bitmap.h\n> @@ -83,7 +83,7 @@ int64_t bdrv_dirty_iter_next(BdrvDirtyBitmapIter *iter);\n>  void bdrv_set_dirty_iter(BdrvDirtyBitmapIter *hbi, int64_t sector_num);\n>  int64_t bdrv_get_dirty_count(BdrvDirtyBitmap *bitmap);\n>  int64_t bdrv_get_meta_dirty_count(BdrvDirtyBitmap *bitmap);\n> -void bdrv_dirty_bitmap_truncate(BlockDriverState *bs);\n> +void bdrv_dirty_bitmap_truncate(BlockDriverState *bs, int64_t bytes);\n>  bool bdrv_dirty_bitmap_readonly(const BdrvDirtyBitmap *bitmap);\n>  bool bdrv_has_readonly_bitmaps(BlockDriverState *bs);\n>  bool bdrv_dirty_bitmap_get_autoload(const BdrvDirtyBitmap *bitmap);\n> diff --git a/block.c b/block.c\n> index 528cda7b2c..ef5af81f66 100644\n> --- a/block.c\n> +++ b/block.c\n> @@ -3545,12 +3545,18 @@ int bdrv_truncate(BdrvChild *child, int64_t offset, PreallocMode prealloc,\n>      assert(!(bs->open_flags & BDRV_O_INACTIVE));\n> \n>      ret = drv->bdrv_truncate(bs, offset, prealloc, errp);\n> -    if (ret == 0) {\n> -        ret = refresh_total_sectors(bs, offset >> BDRV_SECTOR_BITS);\n> -        bdrv_dirty_bitmap_truncate(bs);\n> -        bdrv_parent_cb_resize(bs);\n> -        atomic_inc(&bs->write_gen);\n> +    if (ret < 0) {\n> +        return ret;\n>      }\n> +    ret = refresh_total_sectors(bs, offset >> BDRV_SECTOR_BITS);\n> +    if (ret < 0) {\n> +        error_setg_errno(errp, -ret, \"Could not refresh total sector count\");\n> +    } else {\n> +        offset = bs->total_sectors * BDRV_SECTOR_SIZE;\n> +    }\n> +    bdrv_dirty_bitmap_truncate(bs, offset);\n> +    bdrv_parent_cb_resize(bs);\n> +    atomic_inc(&bs->write_gen);\n>      return ret;\n>  }\n> \n> diff --git a/block/dirty-bitmap.c b/block/dirty-bitmap.c\n> index 42a55e4a4b..ee164fb518 100644\n> --- a/block/dirty-bitmap.c\n> +++ b/block/dirty-bitmap.c\n> @@ -1,7 +1,7 @@\n>  /*\n>   * Block Dirty Bitmap\n>   *\n> - * Copyright (c) 2016 Red Hat. Inc\n> + * Copyright (c) 2016-2017 Red Hat. Inc\n>   *\n>   * Permission is hereby granted, free of charge, to any person obtaining a copy\n>   * of this software and associated documentation files (the \"Software\"), to deal\n> @@ -302,10 +302,10 @@ BdrvDirtyBitmap *bdrv_reclaim_dirty_bitmap(BlockDriverState *bs,\n>   * Truncates _all_ bitmaps attached to a BDS.\n>   * Called with BQL taken.\n>   */\n> -void bdrv_dirty_bitmap_truncate(BlockDriverState *bs)\n> +void bdrv_dirty_bitmap_truncate(BlockDriverState *bs, int64_t bytes)\n>  {\n>      BdrvDirtyBitmap *bitmap;\n> -    uint64_t size = bdrv_nb_sectors(bs);\n> +    int64_t size = DIV_ROUND_UP(bytes, BDRV_SECTOR_SIZE);\n> \n>      bdrv_dirty_bitmaps_lock(bs);\n>      QLIST_FOREACH(bitmap, &bs->dirty_bitmaps, list) {\n> -- \n> 2.13.5\n> \n\nReviewed-by: Fam Zheng <famz@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-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=famz@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 3y1NZz3sydz9t3R\n\tfor <incoming@patchwork.ozlabs.org>;\n\tTue, 26 Sep 2017 11:26:32 +1000 (AEST)","from localhost ([::1]:45119 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 1dwedn-0003l7-7R\n\tfor incoming@patchwork.ozlabs.org; Mon, 25 Sep 2017 21:26:27 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:39460)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <famz@redhat.com>) id 1dwedE-0003j4-Uj\n\tfor qemu-devel@nongnu.org; Mon, 25 Sep 2017 21:25:56 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <famz@redhat.com>) id 1dwedB-0006d9-KA\n\tfor qemu-devel@nongnu.org; Mon, 25 Sep 2017 21:25:50 -0400","from mx1.redhat.com ([209.132.183.28]:51928)\n\tby eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <famz@redhat.com>)\n\tid 1dwed6-0006U2-7u; Mon, 25 Sep 2017 21:25:44 -0400","from smtp.corp.redhat.com\n\t(int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12])\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 09AE3806C4;\n\tTue, 26 Sep 2017 01:25:43 +0000 (UTC)","from localhost (ovpn-12-91.pek2.redhat.com [10.72.12.91])\n\tby smtp.corp.redhat.com (Postfix) with ESMTP id 3AB11756C0;\n\tTue, 26 Sep 2017 01:25:39 +0000 (UTC)"],"DMARC-Filter":"OpenDMARC Filter v1.3.2 mx1.redhat.com 09AE3806C4","Date":"Tue, 26 Sep 2017 09:25:38 +0800","From":"Fam Zheng <famz@redhat.com>","To":"Eric Blake <eblake@redhat.com>","Message-ID":"<20170926012538.GA31924@lemon.lan>","References":"<20170925145526.32690-1-eblake@redhat.com>\n\t<20170925145526.32690-6-eblake@redhat.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<20170925145526.32690-6-eblake@redhat.com>","User-Agent":"Mutt/1.8.3 (2017-05-23)","X-Scanned-By":"MIMEDefang 2.79 on 10.5.11.12","X-Greylist":"Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.26]);\n\tTue, 26 Sep 2017 01:25:43 +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 v10 05/20] dirty-bitmap: Avoid size query\n\tfailure during truncate","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, vsementsov@virtuozzo.com, qemu-block@nongnu.org,\n\tqemu-devel@nongnu.org, Max Reitz <mreitz@redhat.com>, jsnow@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":1778435,"web_url":"http://patchwork.ozlabs.org/comment/1778435/","msgid":"<20171002160615.GG4362@localhost.localdomain>","list_archive_url":null,"date":"2017-10-02T16:06:15","subject":"Re: [Qemu-devel] [PATCH v10 05/20] dirty-bitmap: Avoid size query\n\tfailure during truncate","submitter":{"id":2714,"url":"http://patchwork.ozlabs.org/api/people/2714/","name":"Kevin Wolf","email":"kwolf@redhat.com"},"content":"Am 25.09.2017 um 17:46 hat Eric Blake geschrieben:\n> On 09/25/2017 10:23 AM, Vladimir Sementsov-Ogievskiy wrote:\n> > 25.09.2017 17:55, Eric Blake wrote:\n> >> We've previously fixed several places where we failed to account\n> >> for possible errors from bdrv_nb_sectors().  Fix another one by\n> >> making bdrv_dirty_bitmap_truncate() take the new size from the\n> >> caller instead of querying itself; then adjust the sole caller\n> >> bdrv_truncate() to pass the size just determined by a successful\n> >> resize, or to skip the bitmap resize on failure, thus avoiding\n> > \n> > nothing is skipped in this version\n> \n> So much for me squashing in a change.  If the maintainer is willing\n> (Kevin, is this going through your tree?), we can reword that to:\n> \n> \"...pass the size just determined by a successful resize, or to reuse\n> the size given to the original truncate operation when\n> refresh_total_sectors() was not able to confirm the actual size (the two\n> sizes can potentially differ according to rounding constraints), thus\n> avoiding...\"\n\nI always thought sentences that long were only allowed in German.\n\nAnyway, I'm squashing it in.\n\nKevin","headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@gnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@gnu.org;\n\treceiver=<UNKNOWN>)","ext-mx08.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com","ext-mx08.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 3y5RvV3WDYz9t5s\n\tfor <incoming@patchwork.ozlabs.org>;\n\tTue,  3 Oct 2017 03:09:58 +1100 (AEDT)","from localhost ([::1]:53178 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@gnu.org>)\n\tid 1dz3I4-0003mr-Ji\n\tfor incoming@patchwork.ozlabs.org; Mon, 02 Oct 2017 12:09:56 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:53314)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <kwolf@redhat.com>) id 1dz3Eq-0001Y6-5R\n\tfor qemu-devel@nongnu.org; Mon, 02 Oct 2017 12:06:37 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <kwolf@redhat.com>) id 1dz3Ep-0007Mw-Cw\n\tfor qemu-devel@nongnu.org; Mon, 02 Oct 2017 12:06:36 -0400","from mx1.redhat.com ([209.132.183.28]:43534)\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 1dz3Ej-0007Ba-TI; Mon, 02 Oct 2017 12:06:30 -0400","from smtp.corp.redhat.com\n\t(int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16])\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 CDB49C0587E3;\n\tMon,  2 Oct 2017 16:06:28 +0000 (UTC)","from localhost.localdomain (ovpn-116-161.ams2.redhat.com\n\t[10.36.116.161])\n\tby smtp.corp.redhat.com (Postfix) with ESMTPS id C132590C65;\n\tMon,  2 Oct 2017 16:06:16 +0000 (UTC)"],"DMARC-Filter":"OpenDMARC Filter v1.3.2 mx1.redhat.com CDB49C0587E3","Date":"Mon, 2 Oct 2017 18:06:15 +0200","From":"Kevin Wolf <kwolf@redhat.com>","To":"Eric Blake <eblake@redhat.com>","Message-ID":"<20171002160615.GG4362@localhost.localdomain>","References":"<20170925145526.32690-1-eblake@redhat.com>\n\t<20170925145526.32690-6-eblake@redhat.com>\n\t<f305e22b-963e-f1eb-710c-d74c6efc9628@virtuozzo.com>\n\t<b10bd108-0387-34eb-9aa4-7c5e3f9f63a1@redhat.com>","MIME-Version":"1.0","Content-Type":"multipart/signed; micalg=pgp-sha1;\n\tprotocol=\"application/pgp-signature\"; boundary=\"v9Ux+11Zm5mwPlX6\"","Content-Disposition":"inline","In-Reply-To":"<b10bd108-0387-34eb-9aa4-7c5e3f9f63a1@redhat.com>","User-Agent":"Mutt/1.9.0 (2017-09-02)","X-Scanned-By":"MIMEDefang 2.79 on 10.5.11.16","X-Greylist":"Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.32]);\n\tMon, 02 Oct 2017 16:06:29 +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 v10 05/20] dirty-bitmap: Avoid size query\n\tfailure during truncate","X-BeenThere":"qemu-devel@gnu.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Id":"<qemu-devel.gnu.org>","List-Unsubscribe":"<https://lists.gnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@gnu.org?subject=unsubscribe>","List-Archive":"<http://lists.gnu.org/archive/html/qemu-devel/>","List-Post":"<mailto:qemu-devel@gnu.org>","List-Help":"<mailto:qemu-devel-request@gnu.org?subject=help>","List-Subscribe":"<https://lists.gnu.org/mailman/listinfo/qemu-devel>,\n\t<mailto:qemu-devel-request@gnu.org?subject=subscribe>","Cc":"Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>, famz@redhat.com,\n\tqemu-block@nongnu.org, qemu-devel@nongnu.org,\n\tMax Reitz <mreitz@redhat.com>, jsnow@redhat.com","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@gnu.org","Sender":"\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@gnu.org>"}}]