From: Kevin Wolf <kwolf@redhat.com>
To: Fam Zheng <famz@redhat.com>
Cc: qemu-devel@nongnu.org, Max Reitz <mreitz@redhat.com>,
qemu-block@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] qcow2: Support BDRV_REQ_MAY_UNMAP
Date: Thu, 29 Sep 2016 11:29:17 +0200 [thread overview]
Message-ID: <20160929092917.GC5742@noname.redhat.com> (raw)
In-Reply-To: <1475046261-15679-1-git-send-email-famz@redhat.com>
Am 28.09.2016 um 09:04 hat Fam Zheng geschrieben:
> Handling this is similar to what is done to the L2 entry in the case of
> compressed clusters.
>
> Signed-off-by: Fam Zheng <famz@redhat.com>
> ---
> block/qcow2-cluster.c | 9 +++++----
> block/qcow2.c | 3 ++-
> block/qcow2.h | 3 ++-
> 3 files changed, 9 insertions(+), 6 deletions(-)
>
> diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
> index 61d1ffd..928c1e2 100644
> --- a/block/qcow2-cluster.c
> +++ b/block/qcow2-cluster.c
> @@ -1558,7 +1558,7 @@ fail:
> * clusters.
> */
> static int zero_single_l2(BlockDriverState *bs, uint64_t offset,
> - uint64_t nb_clusters)
> + uint64_t nb_clusters, int flags)
> {
> BDRVQcow2State *s = bs->opaque;
> uint64_t *l2_table;
> @@ -1582,7 +1582,7 @@ static int zero_single_l2(BlockDriverState *bs, uint64_t offset,
>
> /* Update L2 entries */
> qcow2_cache_entry_mark_dirty(bs, s->l2_table_cache, l2_table);
> - if (old_offset & QCOW_OFLAG_COMPRESSED) {
> + if (old_offset & QCOW_OFLAG_COMPRESSED || flags & BDRV_REQ_MAY_UNMAP) {
> l2_table[l2_index + i] = cpu_to_be64(QCOW_OFLAG_ZERO);
> qcow2_free_any_clusters(bs, old_offset, 1, QCOW2_DISCARD_REQUEST);
> } else {
I don't think we should always do this for BDRV_REQ_MAY_UNMAP. The user
may want to keep the image fully allocated even if the guest (or block
job etc.) thinks this can be discarded.
When we discussed this in another email thread (?), I think I suggested
checking whether the image was opened with pass-discard-request=on. If
so, go ahead and deallocate the cluster, otherwise keep it allocated.
In those cases where pass-discard-request=off, it doesn't make a lot of
sense to deallocate the cluster anyway because it won't shrink the file
size.
Kevin
next prev parent reply other threads:[~2016-09-29 9:29 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-28 7:04 [Qemu-devel] [PATCH] qcow2: Support BDRV_REQ_MAY_UNMAP Fam Zheng
2016-09-28 16:11 ` Max Reitz
2016-09-29 2:21 ` Fam Zheng
2016-09-29 7:58 ` Paolo Bonzini
2016-09-29 8:10 ` Fam Zheng
2016-10-01 13:08 ` Max Reitz
2016-09-29 9:29 ` Kevin Wolf [this message]
2016-09-29 9:55 ` Fam Zheng
2016-09-29 10:39 ` Kevin Wolf
2016-09-29 12:14 ` Paolo Bonzini
2016-09-29 12:48 ` Kevin Wolf
2016-09-29 12:50 ` Paolo Bonzini
2016-09-29 12:56 ` Paolo Bonzini
2016-09-30 2:04 ` Fam Zheng
2016-09-30 12:38 ` Kevin Wolf
2016-10-12 1:14 ` Fam Zheng
2016-10-12 8:42 ` Kevin Wolf
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=20160929092917.GC5742@noname.redhat.com \
--to=kwolf@redhat.com \
--cc=famz@redhat.com \
--cc=mreitz@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.