qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] qcow2: Fix qcow2_make_empty() with external data file
@ 2019-04-29 10:57 Kevin Wolf
  2019-04-29 10:57 ` Kevin Wolf
                   ` (4 more replies)
  0 siblings, 5 replies; 14+ messages in thread
From: Kevin Wolf @ 2019-04-29 10:57 UTC (permalink / raw)
  To: qemu-block; +Cc: kwolf, mreitz, qemu-stable, qemu-devel

make_completely_empty() is an optimisated path for bdrv_make_empty()
where completely new metadata is created inside the image file instead
of going through all clusters and discarding them. For an external data
file, however, we actually need to do discard operations on the data
file; just overwriting the qcow2 file doesn't get rid of the data.

The necessary slow path with an explicit discard operation already
exists for other cases. Use it for external data files, too.

Cc: qemu-stable@nongnu.org
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 block/qcow2.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/block/qcow2.c b/block/qcow2.c
index 7fbef97aab..097fde56f9 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -4384,7 +4384,8 @@ static int qcow2_make_empty(BlockDriverState *bs)
 
     if (s->qcow_version >= 3 && !s->snapshots && !s->nb_bitmaps &&
         3 + l1_clusters <= s->refcount_block_size &&
-        s->crypt_method_header != QCOW_CRYPT_LUKS) {
+        s->crypt_method_header != QCOW_CRYPT_LUKS &&
+        !has_data_file(bs)) {
         /* The following function only works for qcow2 v3 images (it
          * requires the dirty flag) and only as long as there are no
          * features that reserve extra clusters (such as snapshots,
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2019-05-01 15:08 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-04-29 10:57 [Qemu-devel] [PATCH] qcow2: Fix qcow2_make_empty() with external data file Kevin Wolf
2019-04-29 10:57 ` Kevin Wolf
2019-04-29 11:21 ` Kevin Wolf
2019-04-29 11:21   ` Kevin Wolf
2019-04-29 14:40   ` Eric Blake
2019-04-29 14:40     ` Eric Blake
2019-04-29 16:13 ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
2019-04-29 16:13   ` Stefan Hajnoczi
2019-04-30 13:54 ` [Qemu-devel] " no-reply
2019-04-30 13:54   ` no-reply
2019-04-30 15:32   ` Eric Blake
2019-04-30 15:32     ` Eric Blake
2019-04-30 15:42 ` no-reply
2019-04-30 15:42   ` no-reply

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).