From: Stefan Hajnoczi <stefanha@gmail.com>
To: Max Reitz <mreitz@redhat.com>
Cc: Kevin Wolf <kwolf@redhat.com>,
qemu-devel@nongnu.org, Stefan Hajnoczi <stefanha@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v4 05/26] qcow2: Use unsigned addend for update_refcount()
Date: Fri, 12 Dec 2014 11:07:51 +0000 [thread overview]
Message-ID: <20141212110751.GC22222@stefanha-thinkpad.redhat.com> (raw)
In-Reply-To: <54897A09.1070606@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 1424 bytes --]
On Thu, Dec 11, 2014 at 12:03:37PM +0100, Max Reitz wrote:
> On 2014-12-11 at 11:58, Stefan Hajnoczi wrote:
> >On Wed, Dec 03, 2014 at 02:37:25PM +0100, Max Reitz wrote:
> >>@@ -530,8 +530,16 @@ found:
> >> }
> >> /* XXX: cache several refcount block clusters ? */
> >>+/* In order to decrease refcounts, set @addend to the two's complement (giving a
> >>+ * negative value and letting the implicit cast handle it is enough) and set
> >>+ * @decrease to true. @decrease must be false if the refcount should be
> >>+ * increased. */
> >The first time I read this patch I missed this quirk and thought that a
> >lot of places seemed to be doing the wrong thing with addend.
> >
> >This is likely to cause confusion, why not make uint16_t addend truly
> >unsigned and leave the sign to bool decrease, as suggested by the
> >function prototype?
>
> Because it's very easy to call it with e.g. target_refcount -
> current_refcount, and using an addition to apply the addend will always
> work.
>
> So, the code is a bit shorter by doing this. On the other hand, I don't have
> trouble making all callers do llabs(addend) or imaxabs(addend) (if the
> absolute value is not known at compile time) and use addition or subtraction
> in this function, depending on the boolean.
I prefer the solution using the absolute value because it makes the code
idiot-proof for me to read :).
Thanks,
Stefan
[-- Attachment #2: Type: application/pgp-signature, Size: 473 bytes --]
next prev parent reply other threads:[~2014-12-12 11:08 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 [this message]
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
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=20141212110751.GC22222@stefanha-thinkpad.redhat.com \
--to=stefanha@gmail.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).