All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Max Reitz <mreitz@redhat.com>, Qemu-block <qemu-block@nongnu.org>,
	Kevin Wolf <kwolf@redhat.com>
Cc: "qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Subject: Re: qcow2: Zero-initialization of external data files
Date: Thu, 9 Apr 2020 08:42:55 -0500	[thread overview]
Message-ID: <ad2542f0-1faf-88eb-9dac-36d87a2a795f@redhat.com> (raw)
In-Reply-To: <8b4bc264-7bce-c9c1-1905-a22b4c61cae4@redhat.com>

On 4/9/20 8:05 AM, Max Reitz wrote:

>>> $ sudo ./qemu-img create -f qcow2 -o \
>>>       data_file=/dev/loop0,data_file_raw=on foo.qcow2 64M
>>> [...]
>>>
>>> $ sudo ./qemu-io -c 'read -P 0 0 64M' foo.qcow2
>>> read 67108864/67108864 bytes at offset 0
>>> 64 MiB, 1 ops; 00.00 sec (25.036 GiB/sec and 400.5751 ops/sec)
>>
>> This looks like a bug (and we should fix it for 5.0 if possible)
> 
> It seems a bit difficult for 5.0 now.  (But I don’t think it’d be a
> regression, so that shouldn’t be too bad.)

So, you're arguing that since 4.2 has the same bug, slipping the fix to 
5.1 instead of 5.0 is not bad because it's not a regression new to 5.0. 
Yes, that's a reasonable answer, if a fix is not fast.


>>> I suppose this behavior is fine for blockdev-create because I guess it’s
>>> the user’s responsibility to ensure that the external data file is zero.
>>>    But maybe it isn’t, so that’s my first question: Is it really the
>>> user’s responsibility or should we always ensure it’s zero?
>>
>> I'd argue that requiring the user to pre-zero the raw data file is
>> undesirable; and that we should instead fix our code to not report the
>> image as reading all zeroes when creating with data_file_raw=on.
> 
> OK.  I think that could be achieved by just enforcing @preallocation to
> be at least “metadata” whenever @data-file-raw is set.  Would that make
> sense?

Is a preallocation of metadata sufficient to report things correctly? 
If so, it seems like a reasonable compromise to me.  I was more 
envisioning a fix elsewhere: if we are reporting block status of what 
looks like an unallocated cluster, but data-file-raw is set, we change 
our answer to instead report it as allocated with unknown contents.  But 
with preallocation, you either force the qcow2 file to list no cluster 
as unallocated (which matches the fact that the raw image really is 
fully allocated) while not touching the raw image, or you can go one 
step further and request full preallocation to wipe the raw image to 0 
in the process.

> 
> Max
> 
>>> My second question is: If we decide that this is fine for
>>> blockdev-create, should at least qcow2_co_create_opts() ensure the data
>>> file it just created is zero?
>>
>> Having an option to make qemu force-zero the raw image during
>> qcow2_co_create_opts seems reasonable, but for performance reasons, I
>> don't think the flag should be on by default.

And by mentioning preallocation, you've managed to convince me that we 
may already have exactly the option I was envisioning.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org



  reply	other threads:[~2020-04-09 13:44 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-17 16:56 qcow2: Zero-initialization of external data files Max Reitz
2020-04-06 22:22 ` Eric Blake
2020-04-09 13:05   ` Max Reitz
2020-04-09 13:42     ` Eric Blake [this message]
2020-04-09 13:47       ` Eric Blake
2020-04-09 14:10         ` Max Reitz
2020-04-09 14:32           ` Eric Blake
2020-04-09 15:01             ` Max Reitz
2020-04-09 15:46               ` Eric Blake
2020-04-09 15:56                 ` Eric Blake
2020-04-14 12:34                   ` Kevin Wolf
2020-04-14 12:28             ` 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=ad2542f0-1faf-88eb-9dac-36d87a2a795f@redhat.com \
    --to=eblake@redhat.com \
    --cc=kwolf@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.