[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-block] [PATCH v3 3/4] qcow2: add shrink image support
From: |
Max Reitz |
Subject: |
Re: [Qemu-block] [PATCH v3 3/4] qcow2: add shrink image support |
Date: |
Mon, 10 Jul 2017 00:08:10 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 |
On 2017-07-07 16:30, Pavel Butsykin wrote:
> This patch add shrinking of the image file for qcow2. As a result, this allows
> us to reduce the virtual image size and free up space on the disk without
> copying the image. Image can be fragmented and shrink is done by punching
> holes
> in the image file.
>
> Signed-off-by: Pavel Butsykin <address@hidden>
> ---
> block/qcow2-cluster.c | 40 +++++++++++++++++++
> block/qcow2-refcount.c | 103
> +++++++++++++++++++++++++++++++++++++++++++++++++
> block/qcow2.c | 42 +++++++++++++++-----
> block/qcow2.h | 14 +++++++
> qapi/block-core.json | 3 +-
> 5 files changed, 191 insertions(+), 11 deletions(-)
[...]
> diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c
> index 0141c9cbe7..443fca6a98 100644
> --- a/block/qcow2-refcount.c
> +++ b/block/qcow2-refcount.c
[...]
> @@ -2945,3 +2946,105 @@ done:
[...]
> + ret = qcow2_cache_get(bs, s->refcount_block_cache, refblock_offs,
> + &refblock);
> + if (ret < 0) {
> + goto out;
> + }
> +
> + if (s->get_refcount(refblock, block_index) != 1) {
> + qcow2_cache_put(bs, s->refcount_block_cache, &refblock);
> + ret = -EINVAL;
Optional: You could mark the image corrupt here.
Anyway:
Reviewed-by: Max Reitz <address@hidden>
> + goto out;
> + }
> + s->set_refcount(refblock, block_index, 0);
signature.asc
Description: OpenPGP digital signature