Add discard_no_unref option for qcow2 images

Qemu 8.1.0 will add discard_no_unref option for qcow2 images.
When this option is enabled (default=false), then it will no longer
unreference clusters when guest does a discard, but it will just free
the blocks (useful for incremental backups for example) and pass the
discard to the lower layer.

This was implemented to avoid fragmentation within the qcow2 image.

Signed-off-by: Jean-Louis Dupond <jean-louis@dupond.be>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Jean-Louis Dupond
2023-06-09 12:47:36 +02:00
committed by Peter Krempa
parent 1092a88e13
commit b855f8ea1e
17 changed files with 171 additions and 7 deletions

View File

@@ -3284,6 +3284,13 @@ paravirtualized driver is specified via the ``disk`` element.
format driver of the ``qemu`` hypervisor can be controlled via the
``max_size`` subelement (see example below).
The optional ``discard_no_unref`` attribute can be set to control the way
the ``qemu`` hypervisor handles guest discard commands inside the qcow2
image. When enabled, a discard request from within the guest will mark the
qcow2 cluster as zero, but will keep the reference/offset of that cluster.
But it will still pass the discard further to the lower layer.
This will resolve fragmentation within the qcow2 image. :since:`Since 9.5.0`
In the majority of cases the default configuration used by the hypervisor
is sufficient so modifying this setting should not be necessary. For
specifics on how the metadata cache of ``qcow2`` in ``qemu`` behaves refer