All of lore.kernel.org
 help / color / mirror / Atom feed
From: Max Reitz <mreitz@redhat.com>
To: Alberto Garcia <berto@igalia.com>, qemu-devel@nongnu.org
Cc: qemu-block@nongnu.org, Kevin Wolf <kwolf@redhat.com>
Subject: Re: [Qemu-devel] [PATCH] qcow2: Optimize the refcount-block overlap check
Date: Wed, 1 Feb 2017 12:58:36 +0100	[thread overview]
Message-ID: <0e44af0e-6319-62f0-1e17-87f91ee1b66e@redhat.com> (raw)
In-Reply-To: <w51inoury83.fsf@maestria.local.igalia.com>

[-- Attachment #1: Type: text/plain, Size: 2633 bytes --]

On 01.02.2017 11:39, Alberto Garcia wrote:
> On Wed 01 Feb 2017 02:46:20 AM CET, Max Reitz <mreitz@redhat.com> wrote:
> 
>>> The problem with the refcount table is that since it always occupies
>>> complete clusters its size is usually very big.
>>
>> Actually the main problem is that BDRVQcow2State.refcount_table_size
>> is updated very generously as opposed to BDRVQcow2State.l1_size. The
>> latter is usually exactly as large as it needs to be (because the L1
>> table size usually doesn't change), whereas the refcount_table_size is
>> just bumped up every time the image gets bigger until it reaches or
>> exceeds the value it needs to be.
> 
> That's actually a good point.
> 
> One reason why this happens is that the size of the L1 table is static
> and the qcow2 header stores the actual number of entries, whereas for
> the refcount table it stores the number of clusters.

The other reason is what I said: The image size changes, so the refcount
table size needs to be bumped up from time to time. The L1 table size is
pretty much static, so it makes sense to keep it exactly as large as it
needs to be to represent all of the virtual disk.

> Maybe we can have refcount_table_size store the actual size of the
> table. The number of clusters can be calculated from that after all, and
> we would get rid of max_refcount_table_index.

refcount_table_size as in the one in BDRVQcow2State? That is the number
of entries already. I don't think making it "exact" is worth it, because
see above (you need to bump it up any time an allocation is made, and
you don't want to reallocate the refcount table all the time).

Also, you lose all of the accuracy once the image is closed and reopened
because the field in the qcow2 header only stores number of clusters.
Changing that would not be backwards compatible. You could add a new
field which stores the number of entries, but I don't see the point, as
it is very easy to just recalculate it once the image is opened (which
doesn't take *that* much time if you do it just once).

> The change might be a bit more difficult, though, I'll take a look.

Well, I won't hold you back, but I don't think it's worth it.

Max

>>> @@ -439,6 +450,7 @@ static int alloc_refcount_block(BlockDriverState *bs,
>>>          }
>>>  
>>>          s->refcount_table[refcount_table_index] = new_block;
>>> +        s->max_refcount_table_index = refcount_table_index;
>>
>> Should be MAX(s->max_refcount_table_index, refcount_table_index) or
>> this won't support refcount tables with holes in them.
> 
> Good catch.
> 
> Berto
> 



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

      reply	other threads:[~2017-02-01 11:58 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-30 16:14 [Qemu-devel] [PATCH] qcow2: Optimize the refcount-block overlap check Alberto Garcia
2017-01-30 16:34 ` Alberto Garcia
2017-01-30 18:27   ` Eric Blake
2017-02-01  1:16   ` Max Reitz
2017-02-01  1:46 ` Max Reitz
2017-02-01 10:39   ` Alberto Garcia
2017-02-01 11:58     ` 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=0e44af0e-6319-62f0-1e17-87f91ee1b66e@redhat.com \
    --to=mreitz@redhat.com \
    --cc=berto@igalia.com \
    --cc=kwolf@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.