qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Kevin Wolf <kwolf@redhat.com>
Cc: vsementsov@virtuozzo.com, berto@igalia.com,
	qemu-devel@nongnu.org, qemu-block@nongnu.org, mreitz@redhat.com
Subject: Re: [PATCH v6 10/10] qcow2: Forward ZERO_WRITE flag for full preallocation
Date: Thu, 23 Apr 2020 11:15:14 -0500	[thread overview]
Message-ID: <61610f75-0e2c-3b59-573e-e2944ae02ad1@redhat.com> (raw)
In-Reply-To: <20200423160410.GF23654@linux.fritz.box>

On 4/23/20 11:04 AM, Kevin Wolf wrote:

>> Hmm.  When we get block status, it is very easy to tell that something reads
>> as zero when the qcow2 file has the zero bit set, but when the qcow2 file
>> does not have the zero bit set, we have to then query the format layer
>> whether it reads as zeros (which is expensive enough for some format layers
>> that we no longer report things as reading as zero). I'm worried that
>> optimizing this case could penalize later block status.
> 
> That's just how preallocation works. If you don't want that, you need
> preallocation=off.

Good point. And if I recall, didn't we already have a discussion (or 
even patches) to optimize whether querying the format layer during block 
status was even worth the effort, depending on heuristics of the size of 
the format layer which in turn is based on whether there was 
preallocation?  So not a show-stopper.

> 
>> We already can tell the difference between a cluster that has the zero bit
>> set but is not preallocated, vs. has the zero bit set and is preallocated.
>> Are we really forcing a copy-on-write to a cluster that is marked zero but
>> preallocated?  Is the problem that we don't have a way to distinguish
>> between 'reads as zeroes, allocated, but we don't know state of format
>> layer' and 'reads as zeroes, allocated, and we know format layer reads as
>> zeroes'?
> 
> Basically, yes. If we had this, we could have a type of cluster where
> writing to it still involves a metadata update (to clear the zero flag),
> but never copy-on-write, even for partial writes.
> 
> I'm not sure if this would cover a very relevant case, though.

I also wonder if Berto's subcluster patches might play into this scenario.

>>
>> Hmm - just noticing things: how does this series interplay with the existing
>> bdrv_has_zero_init_truncate?  Should this series automatically handle
>> BDRV_REQ_ZERO_WRITE on a bdrv_co_truncate(PREALLOC_NONE) request for all
>> drivers that report true, even if that driver does not advertise support for
>> the BDRV_REQ_ZERO_WRITE flag?
> 
> Hmm... It feels risky to me.

Or worded differently, is bdrv_has_zero_init_truncate even still 
necessary (when it is documented only to cover the PREALLOC_NONE case), 
or should we get rid of it in favor of using BDRV_REQ_ZERO_WRITE 
everywhere instead?  (Which in turn involves visiting all drivers that 
previously advertised bdrv_has_zero_init_truncate... but I already have 
work in my tree trying to do that as part of preparing to add an 
autoclear bit to qcow2 to make it faster to report when a qcow2 image is 
known all-zero content...)

Looks like I'll be rebasing my work on top of this series.

> 
>>> +        } else {
>>> +            ret = -1;
>>> +        }
>>
>> Here, ret == -1 does not imply whether errp is set - but annoyingly, errp
>> CAN be set if bdrv_co_truncate() failed.
>>
>>> +        if (ret < 0) {
>>> +            ret = bdrv_co_truncate(bs->file, new_file_size, false, prealloc, 0,
>>> +                                   errp);
>>
>> And here, you are passing a possibly-set errp back to bdrv_co_truncate().
>> That is a bug that can abort.  You need to pass NULL to the first
>> bdrv_co_truncate() call or else clear errp prior to trying a fallback to
>> this second bdrv_co_truncate() call.
> 
> Yes, you're right. If nothing else comes up, I'll fix this while
> applying.
> 
> Kevin
> 

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



  reply	other threads:[~2020-04-23 16:17 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-23 15:01 [PATCH v6 00/10] block: Fix resize (extending) of short overlays Kevin Wolf
2020-04-23 15:01 ` [PATCH v6 01/10] block: Add flags to BlockDriver.bdrv_co_truncate() Kevin Wolf
2020-04-23 15:01 ` [PATCH v6 02/10] block: Add flags to bdrv(_co)_truncate() Kevin Wolf
2020-04-23 15:01 ` [PATCH v6 03/10] block-backend: Add flags to blk_truncate() Kevin Wolf
2020-04-23 15:01 ` [PATCH v6 04/10] qcow2: Support BDRV_REQ_ZERO_WRITE for truncate Kevin Wolf
2020-04-23 15:18   ` Eric Blake
2020-04-23 15:48     ` Kevin Wolf
2020-04-24  6:16   ` Vladimir Sementsov-Ogievskiy
2020-04-24 12:17     ` Kevin Wolf
2020-04-24 14:16       ` Eric Blake
2020-04-24 14:27       ` Vladimir Sementsov-Ogievskiy
2020-04-23 15:01 ` [PATCH v6 05/10] raw-format: " Kevin Wolf
2020-04-24  6:21   ` Vladimir Sementsov-Ogievskiy
2020-04-23 15:01 ` [PATCH v6 06/10] file-posix: " Kevin Wolf
2020-04-23 15:01 ` [PATCH v6 07/10] block: truncate: Don't make backing file data visible Kevin Wolf
2020-04-23 15:21   ` Eric Blake
2020-04-23 17:59   ` Max Reitz
2020-04-24  6:45   ` Vladimir Sementsov-Ogievskiy
2020-04-23 15:01 ` [PATCH v6 08/10] iotests: Filter testfiles out in filter_img_info() Kevin Wolf
2020-04-24  6:51   ` Vladimir Sementsov-Ogievskiy
2020-04-23 15:01 ` [PATCH v6 09/10] iotests: Test committing to short backing file Kevin Wolf
2020-04-24  8:53   ` Vladimir Sementsov-Ogievskiy
2020-04-23 15:01 ` [PATCH v6 10/10] qcow2: Forward ZERO_WRITE flag for full preallocation Kevin Wolf
2020-04-23 15:36   ` Eric Blake
2020-04-23 16:04     ` Kevin Wolf
2020-04-23 16:15       ` Eric Blake [this message]
2020-04-23 18:05   ` Max Reitz

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=61610f75-0e2c-3b59-573e-e2944ae02ad1@redhat.com \
    --to=eblake@redhat.com \
    --cc=berto@igalia.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=vsementsov@virtuozzo.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).