On 25.06.2020 18:21, Max Reitz wrote:
> The condition modified here is not about potentially filtered children,
> but only about COW sources (i.e. traditional backing files).
>
> Signed-off-by: Max Reitz <mreitz@redhat.com>
> ---
> block/io.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/block/io.c b/block/io.c
> index dc9891d6ce..097a3861d8 100644
> --- a/block/io.c
> +++ b/block/io.c
> @@ -3308,7 +3308,7 @@ int coroutine_fn bdrv_co_truncate(BdrvChild *child, int64_t offset, bool exact,
> Error **errp)
> {
> BlockDriverState *bs = child->bs;
> - BdrvChild *filtered;
> + BdrvChild *filtered, *backing;
> BlockDriver *drv = bs->drv;
> BdrvTrackedRequest req;
> int64_t old_size, new_bytes;
> @@ -3361,6 +3361,7 @@ int coroutine_fn bdrv_co_truncate(BdrvChild *child, int64_t offset, bool exact,
> }
>
> filtered = bdrv_filter_child(bs);
> + backing = bdrv_cow_child(bs);
>
> /*
> * If the image has a backing file that is large enough that it would
> @@ -3372,10 +3373,10 @@ int coroutine_fn bdrv_co_truncate(BdrvChild *child, int64_t offset, bool exact,
> * backing file, taking care of keeping things consistent with that backing
> * file is the user's responsibility.
> */
> - if (new_bytes && bs->backing) {
> + if (new_bytes && backing) {
> int64_t backing_len;
>
> - backing_len = bdrv_getlength(backing_bs(bs));
> + backing_len = bdrv_getlength(backing->bs);
> if (backing_len < 0) {
> ret = backing_len;
> error_setg_errno(errp, -ret, "Could not get backing file size");
Reviewed-by: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com>