]> git.ipfire.org Git - thirdparty/qemu.git/commit
qcow2: keep reference on zeroize with discard-no-unref enabled
authorJean-Louis Dupond <jean-louis@dupond.be>
Tue, 3 Oct 2023 12:52:37 +0000 (14:52 +0200)
committerMichael Tokarev <mjt@tls.msk.ru>
Thu, 9 Nov 2023 13:39:13 +0000 (16:39 +0300)
commitcc9f53b3ec140b07328e38167dc44f37f63b7781
tree1165c852a5384b9d9ad0b8c24213df62b80987ec
parentfe8eb3187c35189a3bde8775696468c84a89e96f
qcow2: keep reference on zeroize with discard-no-unref enabled

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>
Message-Id: <20231003125236.216473-2-jean-louis@dupond.be>
[hreitz: Made the documentation change more verbose, as discussed
         on-list]
Signed-off-by: Hanna Czenczek <hreitz@redhat.com>
(cherry picked from commit b2b109041ecd1095384f5be5bb9badd13c1cf286)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
block/qcow2-cluster.c
qapi/block-core.json
qemu-options.hx