qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Max Reitz <mreitz@redhat.com>
To: Pavel Butsykin <pbutsykin@virtuozzo.com>,
	qemu-block@nongnu.org, qemu-devel@nongnu.org
Cc: kwolf@redhat.com, eblake@redhat.com, armbru@redhat.com, den@openvz.org
Subject: Re: [Qemu-devel] [PATCH v4 3/4] qcow2: add shrink image support
Date: Tue, 11 Jul 2017 19:22:31 +0200	[thread overview]
Message-ID: <003c6002-c8b2-a4be-c1ef-3225e170190f@redhat.com> (raw)
In-Reply-To: <20170711124024.1396-4-pbutsykin@virtuozzo.com>

[-- Attachment #1: Type: text/plain, Size: 2283 bytes --]

On 2017-07-11 14:40, 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 <pbutsykin@virtuozzo.com>
> Reviewed-by: Max Reitz <mreitz@redhat.com>
> ---
>  block/qcow2-cluster.c  |  40 ++++++++++++++++++
>  block/qcow2-refcount.c | 110 +++++++++++++++++++++++++++++++++++++++++++++++++
>  block/qcow2.c          |  42 ++++++++++++++-----
>  block/qcow2.h          |  14 +++++++
>  qapi/block-core.json   |   3 +-
>  5 files changed, 198 insertions(+), 11 deletions(-)

[...]

> diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c
> index 0141c9cbe7..e52d1698b5 100644
> --- a/block/qcow2-refcount.c
> +++ b/block/qcow2-refcount.c

[...]

> +    for (i = 0; i < s->refcount_table_size; i++) {
> +        if (s->refcount_table[i] && !reftable_tmp[i]) {
> +            uint64_t discard_offs = s->refcount_table[i] & REFT_OFFSET_MASK;
> +            uint64_t refblock_offs = get_refblock_offset(s, discard_offs);
> +            uint64_t cluster_index = discard_offs >> s->cluster_bits;
> +            uint32_t block_index = cluster_index & (s->refcount_block_size - 1);
> +            void *refblock;
> +
> +            assert(discard_offs != 0);
> +
> +            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_signal_corruption(bs, true, -1, -1, "Invalid refcount:"
> +                                        " refblock offset %#" PRIx64
> +                                        ", reftable index %d"
> +                                        ", block offset %#" PRIx64
> +                                        ", refcount %#" PRIx64,
> +                                        refblock_offs, i, discard_offs,
> +                                        s->get_refcount(refblock, block_index));

Nice, thanks!

Max


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 498 bytes --]

  reply	other threads:[~2017-07-11 17:22 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-11 12:40 [Qemu-devel] [PATCH v4 0/4] Add shrink image for qcow2 Pavel Butsykin
2017-07-11 12:40 ` [Qemu-devel] [PATCH v4 1/4] qemu-img: add --shrink flag for resize Pavel Butsykin
2017-07-11 12:40 ` [Qemu-devel] [PATCH v4 2/4] qcow2: add qcow2_cache_discard Pavel Butsykin
2017-07-11 12:40 ` [Qemu-devel] [PATCH v4 3/4] qcow2: add shrink image support Pavel Butsykin
2017-07-11 17:22   ` Max Reitz [this message]
2017-07-11 12:40 ` [Qemu-devel] [PATCH v4 4/4] qemu-iotests: add shrinking image test Pavel Butsykin
2017-07-11 18:06   ` Max Reitz
2017-07-11 13:14 ` [Qemu-devel] [PATCH v4 0/4] Add shrink image for qcow2 no-reply
2017-07-11 13:35   ` Pavel Butsykin
2017-07-11 23:57     ` Fam Zheng
2017-07-11 14:31 ` no-reply
2017-07-11 18:08 ` Max Reitz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=003c6002-c8b2-a4be-c1ef-3225e170190f@redhat.com \
    --to=mreitz@redhat.com \
    --cc=armbru@redhat.com \
    --cc=den@openvz.org \
    --cc=eblake@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=pbutsykin@virtuozzo.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).