qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Max Reitz <mreitz@redhat.com>
To: Eric Blake <eblake@redhat.com>,
	"Richard W.M. Jones" <rjones@redhat.com>,
	 qemu-devel@nongnu.org, qemu-block@nongnu.org,
	mlevitsk@redhat.com, sgarzare@redhat.com
Subject: Re: Bug? qemu-img convert to preallocated image makes it sparse
Date: Thu, 16 Jan 2020 16:03:46 +0100	[thread overview]
Message-ID: <026ac30d-930c-0c81-0825-346e33e59f36@redhat.com> (raw)
In-Reply-To: <75daaf8f-0bfe-d3f6-5df4-88c29b2d9b07@redhat.com>


[-- Attachment #1.1: Type: text/plain, Size: 1481 bytes --]

On 16.01.20 15:57, Eric Blake wrote:
> On 1/16/20 8:47 AM, Max Reitz wrote:
> 
>> So when you convert to the target image, you have to make sure all areas
>> that are zero in the source are zero in the target, too.  The way we do
>> that is to write zeroes to the target.  The problem is that this
>> operation disregards the previous preallocation and discards the
>> preallocated space.
>>
>> As for fixing the bug...  Can we fix it in qemu(-img)?
>>
>> We could try to detect whether areas that are zero in the source are
>> zero in the (preallocated) target image, too.  But doing so what require
>> reading the data from those areas and comparing it to zero.  That would
>> take time and it isn’t trivial.  So that’s something I’d rather avoid.
> 
> Can't we also use block status queries on the destination, as that is
> likely to be faster than actual reads and comparison to zero?

It might work for falloc preallocation, but I don’t know whether we are
really guaranteed that fallocated() areas return holes through lseek().

It won’t work for full preallocation, though.  Yes, you might get around
that with -S 0 then, but I think overall the simplest thing would be a
--target-is-zero flag.  (I don’t know, it seems useful to me in general.
 For example, when you convert to a new block device.  The biggest
drawback I see is that people might use it blindly and then complain
that their image contains garbage...)

Max


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

      reply	other threads:[~2020-01-16 15:07 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-16 14:13 Bug? qemu-img convert to preallocated image makes it sparse Richard W.M. Jones
2020-01-16 14:37 ` Max Reitz
2020-01-16 14:50   ` Kevin Wolf
2020-01-16 14:55     ` Max Reitz
2020-01-16 15:38       ` Maxim Levitsky
2020-01-16 15:56         ` Max Reitz
2020-01-16 16:00         ` Richard W.M. Jones
2020-01-16 16:02           ` Max Reitz
2020-01-17 10:28   ` David Edmondson
2020-01-16 14:47 ` Max Reitz
2020-01-16 14:53   ` Richard W.M. Jones
2020-01-16 14:57   ` Eric Blake
2020-01-16 15:03     ` Max Reitz [this message]

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=026ac30d-930c-0c81-0825-346e33e59f36@redhat.com \
    --to=mreitz@redhat.com \
    --cc=eblake@redhat.com \
    --cc=mlevitsk@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=rjones@redhat.com \
    --cc=sgarzare@redhat.com \
    /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).