All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alberto Garcia <berto@igalia.com>
To: qemu-devel@nongnu.org
Cc: qemu-block@nongnu.org, Max Reitz <mreitz@redhat.com>,
	Kevin Wolf <kwolf@redhat.com>
Subject: Re: [Qemu-devel] [PATCH] qcow2: Optimize the refcount-block overlap check
Date: Mon, 30 Jan 2017 17:34:29 +0100	[thread overview]
Message-ID: <w51vaswzeui.fsf@maestria.local.igalia.com> (raw)
In-Reply-To: <20170130161441.30493-1-berto@igalia.com>

On Mon 30 Jan 2017 05:14:41 PM CET, Alberto Garcia wrote:

> This patch keeps the index of the last used (i.e. non-zero) entry in
> the refcount table and updates it every time the table changes. The
> refcount-block overlap check then uses that index instead of reading
> the whole table.

Note that while I decided to go for this approach the patch can be made
much simpler by simply stopping at the first empty entry in the refcount
table:

    if ((chk & QCOW2_OL_REFCOUNT_BLOCK) && s->refcount_table) {
        for (i = 0; i < s->refcount_table_size; i++) {
            if (!(s->refcount_table[i] & REFT_OFFSET_MASK)) {
                break;
            }
            if (overlaps_with(s->refcount_table[i] & REFT_OFFSET_MASK,
                s->cluster_size)) {
                return QCOW2_OL_REFCOUNT_BLOCK;
            }
        }
    }

I don't think QEMU produces files where refcount_table[i] == 0 but
refcount_table[i + 1] != 0. Do they even make sense? In any case, my
patch would cover those cases too, but this simplified version wouldn't.

Berto

  reply	other threads:[~2017-01-30 16:34 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 [this message]
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

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=w51vaswzeui.fsf@maestria.local.igalia.com \
    --to=berto@igalia.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.