qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>,
	qemu-devel@nongnu.org, qemu-block@nongnu.org,
	qemu-stable@nongnu.org
Cc: pbonzini@redhat.com, den@openvz.org, John Snow <jsnow@redhat.com>
Subject: Re: [Qemu-devel] [PATCH] nbd/server: fix bitmap export
Date: Fri, 14 Sep 2018 12:35:08 -0500	[thread overview]
Message-ID: <3d127a88-58e9-dd74-e9ea-d13542aff92d@redhat.com> (raw)
In-Reply-To: <ce8e83a8-40c1-1fa9-3d83-c5f84796d514@virtuozzo.com>

On 9/14/18 12:30 PM, Vladimir Sementsov-Ogievskiy wrote:

>>>       while (begin < overall_end && i < nb_extents) {
>>> +        bool next_dirty = !dirty;
>>> +
>>>           if (dirty) {
>>>               end = bdrv_dirty_bitmap_next_zero(bitmap, begin);
>>>           } else {
>>> @@ -1962,6 +1964,7 @@ static unsigned int 
>>> bitmap_to_extents(BdrvDirtyBitmap *bitmap, uint64_t offset,
>>>               end = MIN(bdrv_dirty_bitmap_size(bitmap),
>>>                         begin + UINT32_MAX + 1 -
>>>                         bdrv_dirty_bitmap_granularity(bitmap));
>>> +            next_dirty = dirty;
>>>           }
>>
>> Rather than introducing next_dirty, couldn't you just make this:
>>
>> if (end == -1 || end - begin > UINT32_MAX) {
>>     /* Cap ... */
>>     end = MIN(...);
>> } else {
>>     dirty = !dirty;
>> }
> 
> no, dirty variable is used after it, we can't change it here.

Ah, right. But we could also hoist the extents[i].flags = 
cpu_to_be32(dirty ? NBD_STATEE_DIRTY : 0) line to occur prior to the 
'if' doing the end capping calculation.  However, splitting the two 
assignments into extents[i].* to no longer be consecutive statements, 
just to avoid the use of a temporary variable, starts to get less 
aesthetically pleasing.

Thus, I'm fine with your version (with commit message improved), unless 
you want to send a v2.

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

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org

  reply	other threads:[~2018-09-14 17:35 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-14 16:51 [Qemu-devel] [PATCH] nbd/server: fix bitmap export Vladimir Sementsov-Ogievskiy
2018-09-14 17:24 ` Eric Blake
2018-09-14 17:30   ` Vladimir Sementsov-Ogievskiy
2018-09-14 17:35     ` Eric Blake [this message]
2018-09-14 17:47       ` Vladimir Sementsov-Ogievskiy
2018-09-14 17:38     ` Vladimir Sementsov-Ogievskiy
2018-09-14 18:12   ` Eric Blake

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=3d127a88-58e9-dd74-e9ea-d13542aff92d@redhat.com \
    --to=eblake@redhat.com \
    --cc=den@openvz.org \
    --cc=jsnow@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-stable@nongnu.org \
    --cc=vsementsov@virtuozzo.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).