From: Hanna Czenczek <hreitz@redhat.com>
To: Jean-Louis Dupond <jean-louis@dupond.be>,
qemu-devel@nongnu.org, kwolf@redhat.com
Subject: Re: [PATCH v3] qcow2: add discard-no-unref option
Date: Mon, 5 Jun 2023 10:51:23 +0200 [thread overview]
Message-ID: <d27bee66-8d23-bee7-57ab-27f59ac26812@redhat.com> (raw)
In-Reply-To: <20230605084523.34134-2-jean-louis@dupond.be>
On 05.06.23 10:45, Jean-Louis Dupond wrote:
> When we for example have a sparse qcow2 image and discard: unmap is enabled,
> there can be a lot of fragmentation in the image after some time. Especially on VM's
> that do a lot of writes/deletes.
> This causes the qcow2 image to grow even over 110% of its virtual size,
> because the free gaps in the image get too small to allocate new
> continuous clusters. So it allocates new space at the end of the image.
>
> Disabling discard is not an option, as discard is needed to keep the
> incremental backup size as low as possible. Without discard, the
> incremental backups would become large, as qemu thinks it's just dirty
> blocks but it doesn't know the blocks are unneeded.
> So we need to avoid fragmentation but also 'empty' the unneeded blocks in
> the image to have a small incremental backup.
>
> In addition, we also want to send the discards further down the stack, so
> the underlying blocks are still discarded.
>
> Therefor we introduce a new qcow2 option "discard-no-unref".
> When setting this option to true, discards will no longer have the qcow2
> driver relinquish cluster allocations. Other than that, the request is
> handled as normal: All clusters in range are marked as zero, and, if
> pass-discard-request is true, it is passed further down the stack.
> The only difference is that the now-zero clusters are preallocated
> instead of being unallocated.
> This will avoid fragmentation on the qcow2 image.
>
> Fixes: https://gitlab.com/qemu-project/qemu/-/issues/1621
> Signed-off-by: Jean-Louis Dupond <jean-louis@dupond.be>
> ---
> block/qcow2-cluster.c | 32 ++++++++++++++++++++++++++++----
> block/qcow2.c | 18 ++++++++++++++++++
> block/qcow2.h | 3 +++
> qapi/block-core.json | 12 ++++++++++++
> qemu-options.hx | 12 ++++++++++++
> 5 files changed, 73 insertions(+), 4 deletions(-)
Thanks!
Reviewed-by: Hanna Czenczek <hreitz@redhat.com>
prev parent reply other threads:[~2023-06-05 8:52 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-05 8:45 [PATCH v3] qcow2: add discard-no-unref option Jean-Louis Dupond
2023-06-05 8:51 ` Hanna Czenczek [this message]
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=d27bee66-8d23-bee7-57ab-27f59ac26812@redhat.com \
--to=hreitz@redhat.com \
--cc=jean-louis@dupond.be \
--cc=kwolf@redhat.com \
--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).