qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: John Snow <jsnow@redhat.com>
To: Eric Blake <eblake@redhat.com>,
	Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>,
	qemu-block@nongnu.org
Cc: fam@euphon.net, kwolf@redhat.com, quintela@redhat.com,
	qemu-devel@nongnu.org, armbru@redhat.com, stefanha@redhat.com,
	den@openvz.org, mreitz@redhat.com, dgilbert@redhat.com
Subject: Re: [Qemu-devel] [PATCH 4/4] block/dirty-bitmap: refactor bdrv_dirty_bitmap_next
Date: Thu, 26 Sep 2019 17:44:01 -0400	[thread overview]
Message-ID: <9903ca0b-07f5-6c18-1a32-58e65ee27f9c@redhat.com> (raw)
In-Reply-To: <0386d7d0-1bda-054b-89d6-6b179d37b46d@redhat.com>



On 9/26/19 3:28 PM, Eric Blake wrote:
> On 9/26/19 1:54 PM, John Snow wrote:
>>
>>
>> On 9/16/19 10:19 AM, Vladimir Sementsov-Ogievskiy wrote:
>>> bdrv_dirty_bitmap_next is always used in same pattern. So, split it
>>> into _next and _first, instead of combining two functions into one and
>>> add FOR_EACH_DIRTY_BITMAP macro.
>>>
>>> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
>>> ---
>>>   include/block/dirty-bitmap.h   |  9 +++++++--
>>>   block.c                        |  4 +---
>>>   block/dirty-bitmap.c           | 11 +++++++----
>>>   block/qcow2-bitmap.c           |  8 ++------
>>>   migration/block-dirty-bitmap.c |  4 +---
>>>   5 files changed, 18 insertions(+), 18 deletions(-)
>>
>> I'm not as sure that this is an improvement.
>>
> 
>>>   bool bdrv_has_changed_persistent_bitmaps(BlockDriverState *bs);
>>> -BdrvDirtyBitmap *bdrv_dirty_bitmap_next(BlockDriverState *bs,
>>> -                                        BdrvDirtyBitmap *bitmap);
>>> +
>>> +BdrvDirtyBitmap *bdrv_dirty_bitmap_first(BlockDriverState *bs);
>>> +BdrvDirtyBitmap *bdrv_dirty_bitmap_next(BdrvDirtyBitmap *bitmap);
>>> +#define FOR_EACH_DIRTY_BITMAP(bs, bitmap) \
>>> +for (bitmap = bdrv_dirty_bitmap_first(bs); bitmap; \
>>> +     bitmap = bdrv_dirty_bitmap_next(bitmap))
>>> +
> 
> If you want the macro, you can do that without splitting the function in
> two:
> 
> #define FOR_EACH_DIRTY_BITMAP(bs, bitmap) \
> for (bitmap = bdrv_dirty_bitmap_next(bs, NULL); bitmap; \
>      bitmap = bdrv_dirty_bitmap_next(bs, bitmap))
> 
> 
>>
>> Well, I guess explicit first and next functions is harder to mess up,
>> anyway.
>>
>> Reviewed-by: John Snow <jsnow@redhat.com>
>>
>> (Any other thoughts?)
> 
> I don't mind the macro as much (since we already use iteration macros
> for QTAILQ_FOREACH and such throughout the codebase, and since it
> somewhat isolates you from the calling conventions of passing NULL to
> prime the iteration), but introducing the macro does not imply that we
> need two functions.  So I think this is, to some extent, a question of
> the maintainer's sense of aesthetics, and not an actual problem in the
> code.
> 
No harm in taking it and it's easier than not taking it.

Thanks, applied to my bitmaps tree:

https://github.com/jnsnow/qemu/commits/bitmaps
https://github.com/jnsnow/qemu.git

--js


  reply	other threads:[~2019-09-26 21:46 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-16 14:19 [Qemu-devel] [PATCH 0/4] bitmaps: some refactoring Vladimir Sementsov-Ogievskiy
2019-09-16 14:19 ` [Qemu-devel] [PATCH 1/4] block/dirty-bitmap: drop meta Vladimir Sementsov-Ogievskiy
2019-09-16 17:53   ` John Snow
2019-09-16 14:19 ` [Qemu-devel] [PATCH 2/4] block/dirty-bitmap: add bs link Vladimir Sementsov-Ogievskiy
2019-09-18 23:04   ` John Snow
2019-09-16 14:19 ` [Qemu-devel] [PATCH 3/4] block/dirty-bitmap: drop BdrvDirtyBitmap.mutex Vladimir Sementsov-Ogievskiy
2019-09-26 18:40   ` John Snow
2019-09-16 14:19 ` [Qemu-devel] [PATCH 4/4] block/dirty-bitmap: refactor bdrv_dirty_bitmap_next Vladimir Sementsov-Ogievskiy
2019-09-26 18:54   ` John Snow
2019-09-26 19:28     ` Eric Blake
2019-09-26 21:44       ` John Snow [this message]
2019-09-27  7:17         ` Vladimir Sementsov-Ogievskiy

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=9903ca0b-07f5-6c18-1a32-58e65ee27f9c@redhat.com \
    --to=jsnow@redhat.com \
    --cc=armbru@redhat.com \
    --cc=den@openvz.org \
    --cc=dgilbert@redhat.com \
    --cc=eblake@redhat.com \
    --cc=fam@euphon.net \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.com \
    --cc=stefanha@redhat.com \
    --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).