qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Jean-Louis Dupond <jean-louis@dupond.be>
To: Hanna Czenczek <hreitz@redhat.com>,
	qemu-devel@nongnu.org, kwolf@redhat.com
Subject: Re: [PATCH v3] qcow2: keep reference on zeroize with discard-no-unref enabled
Date: Fri, 27 Oct 2023 12:18:41 +0200	[thread overview]
Message-ID: <5ac70f50-6084-4d21-8f11-0f666b69383c@dupond.be> (raw)
In-Reply-To: <9b6735e5-3ce2-448e-a347-70fd5cf169f2@redhat.com>


On 27/10/2023 11:49, Hanna Czenczek wrote:
> On 03.10.23 14:52, Jean-Louis Dupond wrote:
>> When the discard-no-unref flag is enabled, we keep the reference for
>> normal discard requests.
>> But when a discard is executed on a snapshot/qcow2 image with backing,
>> the discards are saved as zero clusters in the snapshot image.
>>
>> When committing the snapshot to the backing file, not
>> discard_in_l2_slice is called but zero_in_l2_slice. Which did not had
>> any logic to keep the reference when discard-no-unref is enabled.
>>
>> Therefor we add logic in the zero_in_l2_slice call to keep the reference
>> on commit.
>>
>> Fixes: https://gitlab.com/qemu-project/qemu/-/issues/1621
>> Signed-off-by: Jean-Louis Dupond <jean-louis@dupond.be>
>> ---
>>   block/qcow2-cluster.c | 22 ++++++++++++++++++----
>>   qapi/block-core.json  |  7 ++++---
>>   qemu-options.hx       |  3 ++-
>>   3 files changed, 24 insertions(+), 8 deletions(-)
>
> [...]
>
>> diff --git a/qapi/block-core.json b/qapi/block-core.json
>> index 89751d81f2..9836195850 100644
>> --- a/qapi/block-core.json
>> +++ b/qapi/block-core.json
>> @@ -3476,15 +3476,16 @@
>>   #     should be issued on other occasions where a cluster gets freed
>>   #
>>   # @discard-no-unref: when enabled, discards from the guest will not
>> -#     cause cluster allocations to be relinquished.  This prevents
>> +#     cause cluster allocations to be relinquished. The same will
>> +#     happen for discards triggered by zeroize. This prevents
>
> I don’t think “zeroize” has any meaning outside of qemu’s qcow2 code.  
> I’d write “when enabled, data clusters will remain preallocated when 
> they are no longer used, e.g. because they are discarded or converted 
> to zero clusters.  As usual, whether the old data is discarded or kept 
> on the protocol level (i.e. in the image file) depends on the setting 
> of the pass-discard-request option. Keeping the clusters preallocated 
> prevents qcow2 fragmentation that would otherwise be caused by freeing 
> and re-allocating them later. Besides potential performance 
> degradation, [...]”
>
> If you’re OK with that, I can change that (here and in 
> qemu-options.hx) when taking the patch.

Perfect!

>
>>   #     qcow2 fragmentation that would be caused by such discards.
>>   #     Besides potential performance degradation, such fragmentation
>>   #     can lead to increased allocation of clusters past the end of the
>>   #     image file, resulting in image files whose file length can grow
>> -#     much larger than their guest disk size would suggest.  If image
>> +#     much larger than their guest disk size would suggest. If image
>>   #     file length is of concern (e.g. when storing qcow2 images
>>   #     directly on block devices), you should consider enabling this
>> -#     option.  (since 8.1)
>> +#     option. (since 8.1)
>
> These two changes don’t seem related, I’d remove them, too. 
> (Double-space after '.' is fairly common in block-core.json, and in my 
> emails, too. :))
Fine
>
> Hanna
>

Thanks
Jean-Louis



  reply	other threads:[~2023-10-27 10:19 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-03 12:52 [PATCH v3] qcow2: keep reference on zeroize with discard-no-unref enabled Jean-Louis Dupond
2023-10-27  9:49 ` Hanna Czenczek
2023-10-27 10:18   ` Jean-Louis Dupond [this message]
2023-10-30 17:03 ` Hanna Czenczek

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=5ac70f50-6084-4d21-8f11-0f666b69383c@dupond.be \
    --to=jean-louis@dupond.be \
    --cc=hreitz@redhat.com \
    --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).