qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Anton Nefedov <anton.nefedov@virtuozzo.com>
To: Alberto Garcia <berto@igalia.com>, qemu-devel@nongnu.org
Cc: qemu-block@nongnu.org, kwolf@redhat.com, mreitz@redhat.com,
	eblake@redhat.com, den@virtuozzo.com
Subject: Re: [Qemu-devel] [PATCH v8 8/9] qcow2: skip writing zero buffers to empty COW areas
Date: Fri, 16 Mar 2018 18:09:22 +0300	[thread overview]
Message-ID: <dcfa7d9b-2efd-dc2d-3e66-0a8d3331ce9e@virtuozzo.com> (raw)
In-Reply-To: <w51d104p1el.fsf@maestria.local.igalia.com>



On 16/3/2018 4:58 PM, Alberto Garcia wrote:
> On Mon 12 Mar 2018 11:16:57 AM CET, Anton Nefedov wrote:
>> --- a/qapi/block-core.json
>> +++ b/qapi/block-core.json
>> @@ -2584,6 +2584,8 @@
>>   #
>>   # @cor_write: a write due to copy-on-read (since 2.11)
>>   #
>> +# @cluster_alloc_space: an allocation of a cluster file space (since 2.12)

now it's 2.13 I believe

> 
> That doesn't sound like correct English to me.
> 

how about
   "an allocation of file space for a cluster"

>> +static bool is_unallocated(BlockDriverState *bs, int64_t offset, int64_t bytes)
>> +{
>> +    int64_t nr;
>> +    return !bytes ||
>> +        (!bdrv_is_allocated_above(bs, NULL, offset, bytes, &nr) && nr == bytes);
>> +}
>> +
> 
> Is this really more efficient than the previous is_zero() call ?
> 
> It seems that in both cases the code ends up calling
> bdrv_common_block_status_above().
> 

the difference is that is_allocated passes 'want_zero = 0'.
It hints drivers to skip thorough seeks for zeroes (e.g. file-posix
returns (BDRV_BLOCK_DATA | BDRV_BLOCK_OFFSET_VALID) right away).
Moreover, bdrv_co_block_status() even skips the check in local_file
unless the protocol driver returned BDRV_BLOCK_RAW.

>> +static bool is_zero_cow(BlockDriverState *bs, QCowL2Meta *m)
>> +{
>> +    /* content with false negatives, giving is_allocated() is faster than
>> +     * a proper zero detection with possible actual image seeks, which is
>> +     * performed by is_zero() */
> 
> It took me a bit to understand this sentence, maybe some native English
> speaker can suggest an alternate wording?
> 
>    "is_allocated() is not as accurate as is_zero() and can give us some
>     false negatives, but it is much more efficient so let's use it here"
> 

wording is the hardest part of it all :)
maybe:

   /* This check is designed for optimization shortcut so it must be
    * efficient.
    * Instead of is_zero(), use is_unallocated() as it is faster (but not
    * as accurate and can result in false negatives). */

>> +    return is_unallocated(bs, m->offset + m->cow_start.offset,
>> +                          m->cow_start.nb_bytes) &&
>> +           is_unallocated(bs, m->offset + m->cow_end.offset,
>> +                          m->cow_end.nb_bytes);
>> +}
> 
> Berto
> 

  reply	other threads:[~2018-03-16 15:09 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-12 10:16 [Qemu-devel] [PATCH v8 0/9] qcow2: cluster space preallocation Anton Nefedov
2018-03-12 10:16 ` [Qemu-devel] [PATCH v8 1/9] mirror: inherit supported write/zero flags Anton Nefedov
2018-03-16 10:35   ` Alberto Garcia
2018-03-12 10:16 ` [Qemu-devel] [PATCH v8 2/9] blkverify: set " Anton Nefedov
2018-03-12 10:16 ` [Qemu-devel] [PATCH v8 3/9] quorum: " Anton Nefedov
2018-03-16 10:39   ` Alberto Garcia
2018-03-12 10:16 ` [Qemu-devel] [PATCH v8 4/9] block: introduce BDRV_REQ_ALLOCATE flag Anton Nefedov
2018-03-16 11:01   ` Alberto Garcia
2018-03-16 14:52     ` Anton Nefedov
2018-03-12 10:16 ` [Qemu-devel] [PATCH v8 5/9] block: treat BDRV_REQ_ALLOCATE as serialising Anton Nefedov
2018-03-19 11:02   ` Alberto Garcia
2018-03-12 10:16 ` [Qemu-devel] [PATCH v8 6/9] file-posix: support BDRV_REQ_ALLOCATE Anton Nefedov
2018-03-16 14:53   ` Anton Nefedov
2018-03-12 10:16 ` [Qemu-devel] [PATCH v8 7/9] block: support BDRV_REQ_ALLOCATE in passthrough drivers Anton Nefedov
2018-03-16 11:03   ` Alberto Garcia
2018-03-12 10:16 ` [Qemu-devel] [PATCH v8 8/9] qcow2: skip writing zero buffers to empty COW areas Anton Nefedov
2018-03-16 13:58   ` Alberto Garcia
2018-03-16 15:09     ` Anton Nefedov [this message]
2018-03-12 10:16 ` [Qemu-devel] [PATCH v8 9/9] iotest 134: test cluster-misaligned encrypted write Anton Nefedov

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=dcfa7d9b-2efd-dc2d-3e66-0a8d3331ce9e@virtuozzo.com \
    --to=anton.nefedov@virtuozzo.com \
    --cc=berto@igalia.com \
    --cc=den@virtuozzo.com \
    --cc=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 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).