qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Max Reitz <mreitz@redhat.com>, qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>, Stefan Hajnoczi <stefanha@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v4 09/26] qcow2: Helper for refcount array reallocation
Date: Wed, 03 Dec 2014 11:00:04 -0700	[thread overview]
Message-ID: <547F4FA4.8000105@redhat.com> (raw)
In-Reply-To: <1417613866-25890-10-git-send-email-mreitz@redhat.com>

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

On 12/03/2014 06:37 AM, Max Reitz wrote:
> Add a helper function for reallocating a refcount array, independent of
> the refcount order. The newly allocated space is zeroed and the function
> handles failed reallocations gracefully.
> 
> The helper function will always align the buffer size to a cluster
> boundary; if storing the refcounts in such an array in big endian byte
> order, this makes it possible to write parts of the array directly as
> refcount blocks into the image file.
> 
> Signed-off-by: Max Reitz <mreitz@redhat.com>
> ---
>  block/qcow2-refcount.c | 137 +++++++++++++++++++++++++++++++------------------
>  1 file changed, 88 insertions(+), 49 deletions(-)
> 
> diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c
> index 152ca22..8bb5167 100644
> --- a/block/qcow2-refcount.c
> +++ b/block/qcow2-refcount.c
> @@ -1130,6 +1130,70 @@ fail:
>  /* refcount checking functions */
>  
>  
> +static size_t refcount_array_byte_size(BDRVQcowState *s, uint64_t entries)
> +{
> +    if (s->refcount_order < 3) {
> +        /* sub-byte width */
> +        int shift = 3 - s->refcount_order;
> +        return (entries + (1 << shift) - 1) >> shift;

Bikeshedding: Should this use DIV_ROUND_UP(entries, 1 << shift)?
Either way,

Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


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

  reply	other threads:[~2014-12-03 18:00 UTC|newest]

Thread overview: 73+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-03 13:37 [Qemu-devel] [PATCH v4 00/26] qcow2: Support refcount orders != 4 Max Reitz
2014-12-03 13:37 ` [Qemu-devel] [PATCH v4 01/26] qcow2: Add two new fields to BDRVQcowState Max Reitz
2014-12-03 14:51   ` Eric Blake
2014-12-10 15:08   ` Stefan Hajnoczi
2014-12-03 13:37 ` [Qemu-devel] [PATCH v4 02/26] qcow2: Add refcount_bits to format-specific info Max Reitz
2014-12-03 15:09   ` Eric Blake
2014-12-10 15:14   ` Stefan Hajnoczi
2014-12-03 13:37 ` [Qemu-devel] [PATCH v4 03/26] qcow2: Do not return new value after refcount update Max Reitz
2014-12-03 15:13   ` Eric Blake
2014-12-10 15:15   ` Stefan Hajnoczi
2014-12-03 13:37 ` [Qemu-devel] [PATCH v4 04/26] qcow2: Only return status from qcow2_get_refcount Max Reitz
2014-12-03 15:37   ` Eric Blake
2014-12-10 15:32   ` Stefan Hajnoczi
2014-12-03 13:37 ` [Qemu-devel] [PATCH v4 05/26] qcow2: Use unsigned addend for update_refcount() Max Reitz
2014-12-03 15:55   ` Eric Blake
2014-12-11 10:58   ` Stefan Hajnoczi
2014-12-11 11:03     ` Max Reitz
2014-12-12 11:07       ` Stefan Hajnoczi
2014-12-03 13:37 ` [Qemu-devel] [PATCH v4 06/26] qcow2: Use 64 bits for refcount values Max Reitz
2014-12-03 16:11   ` Eric Blake
2014-12-03 16:18     ` Max Reitz
2014-12-11 11:04   ` Stefan Hajnoczi
2014-12-03 13:37 ` [Qemu-devel] [PATCH v4 07/26] qcow2: Respect error in qcow2_alloc_bytes() Max Reitz
2014-12-03 17:12   ` Eric Blake
2014-12-11 11:10   ` Stefan Hajnoczi
2014-12-03 13:37 ` [Qemu-devel] [PATCH v4 08/26] qcow2: Refcount overflow and qcow2_alloc_bytes() Max Reitz
2014-12-03 17:41   ` Eric Blake
2014-12-11 11:12   ` Stefan Hajnoczi
2014-12-03 13:37 ` [Qemu-devel] [PATCH v4 09/26] qcow2: Helper for refcount array reallocation Max Reitz
2014-12-03 18:00   ` Eric Blake [this message]
2014-12-11 11:26   ` Stefan Hajnoczi
2014-12-03 13:37 ` [Qemu-devel] [PATCH v4 10/26] qcow2: Helper function for refcount modification Max Reitz
2014-12-03 18:48   ` Eric Blake
2014-12-11 13:36   ` Stefan Hajnoczi
2014-12-03 13:37 ` [Qemu-devel] [PATCH v4 11/26] qcow2: More helpers " Max Reitz
2014-12-03 19:17   ` Eric Blake
2014-12-11 13:40   ` Stefan Hajnoczi
2014-12-03 13:37 ` [Qemu-devel] [PATCH v4 12/26] qcow2: Open images with refcount order != 4 Max Reitz
2014-12-03 13:37 ` [Qemu-devel] [PATCH v4 13/26] qcow2: refcount_order parameter for qcow2_create2 Max Reitz
2014-12-03 19:29   ` Eric Blake
2014-12-11 13:41   ` Stefan Hajnoczi
2014-12-03 13:37 ` [Qemu-devel] [PATCH v4 14/26] qcow2: Use symbolic macros in qcow2_amend_options Max Reitz
2014-12-03 19:48   ` Eric Blake
2014-12-11 14:05   ` Stefan Hajnoczi
2014-12-03 13:37 ` [Qemu-devel] [PATCH v4 15/26] iotests: Prepare for refcount_bits option Max Reitz
2014-12-03 22:05   ` Eric Blake
2014-12-11 14:26   ` Stefan Hajnoczi
2014-12-03 13:37 ` [Qemu-devel] [PATCH v4 16/26] qcow2: Allow creation with refcount order != 4 Max Reitz
2014-12-03 23:02   ` Eric Blake
2014-12-11 14:41   ` Stefan Hajnoczi
2014-12-03 13:37 ` [Qemu-devel] [PATCH v4 17/26] progress: Allow regressing progress Max Reitz
2014-12-03 23:03   ` Eric Blake
2014-12-11 14:41   ` Stefan Hajnoczi
2014-12-03 13:37 ` [Qemu-devel] [PATCH v4 18/26] block: Add opaque value to the amend CB Max Reitz
2014-12-11 14:42   ` Stefan Hajnoczi
2014-12-03 13:37 ` [Qemu-devel] [PATCH v4 19/26] qcow2: Use error_report() in qcow2_amend_options() Max Reitz
2014-12-03 13:37 ` [Qemu-devel] [PATCH v4 20/26] qcow2: Use abort() instead of assert(false) Max Reitz
2014-12-03 13:37 ` [Qemu-devel] [PATCH v4 21/26] qcow2: Split upgrade/downgrade paths for amend Max Reitz
2014-12-03 13:37 ` [Qemu-devel] [PATCH v4 22/26] qcow2: Use intermediate helper CB " Max Reitz
2014-12-11 14:44   ` Stefan Hajnoczi
2014-12-03 13:37 ` [Qemu-devel] [PATCH v4 23/26] qcow2: Add function for refcount order amendment Max Reitz
2014-12-03 23:30   ` Eric Blake
2014-12-11 17:08   ` Stefan Hajnoczi
2014-12-03 13:37 ` [Qemu-devel] [PATCH v4 24/26] qcow2: Invoke refcount order amendment function Max Reitz
2014-12-03 23:35   ` Eric Blake
2014-12-11 14:46   ` Stefan Hajnoczi
2014-12-03 13:37 ` [Qemu-devel] [PATCH v4 25/26] qcow2: Point to amend function in check Max Reitz
2014-12-11 14:46   ` Stefan Hajnoczi
2014-12-03 13:37 ` [Qemu-devel] [PATCH v4 26/26] iotests: Add test for different refcount widths Max Reitz
2014-12-04  0:03   ` Eric Blake
2014-12-04  9:51     ` Max Reitz
2014-12-04 19:10       ` Eric Blake
2014-12-05  9:02         ` 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=547F4FA4.8000105@redhat.com \
    --to=eblake@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@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).