All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anton Nefedov <anton.nefedov@virtuozzo.com>
To: Markus Armbruster <armbru@redhat.com>, Eric Blake <eblake@redhat.com>
Cc: qemu-devel@nongnu.org, kwolf@redhat.com, den@virtuozzo.com,
	qemu-block@nongnu.org, mreitz@redhat.com, pbonzini@redhat.com,
	jsnow@redhat.com
Subject: Re: [Qemu-devel] [PATCH v2 8/8] qapi: query-blockstat: add driver specific file-posix stats
Date: Mon, 12 Feb 2018 19:38:34 +0300	[thread overview]
Message-ID: <8639a69c-ca85-d11b-7aaa-e67ffb660991@virtuozzo.com> (raw)
In-Reply-To: <87tvuyf4it.fsf@dusky.pond.sub.org>



On 3/2/2018 6:59 PM, Markus Armbruster wrote:
> Eric Blake <eblake@redhat.com> writes:
> 
>> On 01/19/2018 06:50 AM, Anton Nefedov wrote:
>>> +
>>> +##
>>> +# @BlockDriverStats:
>>> +#
>>> +# Statistics of a block driver (driver-specific)
>>> +#
>>> +# Since: 2.12
>>> +##
>>> +{ 'union': 'BlockDriverStats',
>>> +  'data': {
>>> +      'file': 'BlockDriverStatsFile'
>>> +  } }
>>
>> Markus has been adamant that we add no new "simple unions" (unions with
>> a 'discriminator' field) - because they are anything but simple in the
>> long run.
> 
> Indeed.  You could make this a flat union, similar to BlockdevOptions:
> 
> { 'union': 'BlockDriverStats':
>    'base': { 'driver': 'BlockdevDriver' },
>    'discriminator': 'driver',
>    'data': {
>        'file': 'BlockDriverStatsFile',
>        ... } }
> 
> However:
> 
>>> +
>>> +##
>>>   # @BlockStats:
>>>   #
>>>   # Statistics of a virtual block device or a block backing device.
>>> @@ -785,6 +819,8 @@
>>>   #
>>>   # @stats:  A @BlockDeviceStats for the device.
>>>   #
>>> +# @driver-stats: Optional driver-specific statistics. (Since 2.12)
>>> +#
>>>   # @parent: This describes the file block device if it has one.
>>>   #          Contains recursively the statistics of the underlying
>>>   #          protocol (e.g. the host file for a qcow2 image). If there is
>>> @@ -798,6 +834,7 @@
>>>   { 'struct': 'BlockStats',
>>>     'data': {'*device': 'str', '*node-name': 'str',
>>>              'stats': 'BlockDeviceStats',
>>> +           '*driver-stats': 'BlockDriverStats',
> 
> You're adding a union of driver-specific stats to a struct of generic
> stats.  That's unnecessarily complicated.  Instead, turn the struct of
> generic stats into a flat union, like this:
> 
> { 'union': 'BlockStats',
>    'base': { ... the generic stats, i.e. the members of BlockStats
>              before this patch ...
>              'driver': 'BlockdevDriver' }
>    'discriminator': 'driver',
>    'data': {
>        'file': 'BlockDriverStatsFile',
>        ... } }
> 
>> ...[1] You are using it alongside a struct that already uses '-'
>> (node-name), so you should use dashes.
>>
>> So, the difference between your proposal (a simple union) and using a
>> "flat union", on the wire, is yours:
>>
>> "return": { ..., "driver-stats": { "type": "file", "data": {
>> "discard_nb_ok: ... } } }
>>
>> vs. a flat union:
>>
>> "return": { ..., "driver-stats": { "driver": "file", "discard-nb-ok":
>> ... } }
>>
>> where you can benefit from less nesting and a saner discriminator name.
> 
> My proposal peels off yet another level of nesting.
> 

The output is better indeed, thanks; a little drawback is now we need to
pass the whole BlockStats to the driver so it fills its stats.

e.g. the interface:

     void (*bdrv_get_stats)(BlockDriverState *bs, BlockStats *stats);

And that BlockdevDriver subset type (or a generator patch) still seems
to be needed

   { 'enum' : 'BlockdevDriverWithStats',
     'data' : [ 'file' ] }

  reply	other threads:[~2018-02-12 16:38 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-19 12:49 [Qemu-devel] [PATCH v2 0/8] discard blockstats Anton Nefedov
2018-01-19 12:50 ` [Qemu-devel] [PATCH v2 1/8] qapi: group BlockDeviceStats fields Anton Nefedov
2018-02-06 13:12   ` [Qemu-devel] [Qemu-block] " Alberto Garcia
2018-02-12 16:18     ` Anton Nefedov
2018-01-19 12:50 ` [Qemu-devel] [PATCH v2 2/8] qapi: add unmap to BlockDeviceStats Anton Nefedov
2018-01-22 20:47   ` Eric Blake
2018-01-23 10:35     ` Anton Nefedov
2018-01-19 12:50 ` [Qemu-devel] [PATCH v2 3/8] ide: account UNMAP (TRIM) operations Anton Nefedov
2018-01-22 20:48   ` Eric Blake
2018-01-23 10:39     ` Anton Nefedov
2018-02-07 14:39   ` [Qemu-devel] [Qemu-block] " Alberto Garcia
2018-01-19 12:50 ` [Qemu-devel] [PATCH v2 4/8] scsi: store unmap offset and nb_sectors in request struct Anton Nefedov
2018-01-19 12:50 ` [Qemu-devel] [PATCH v2 5/8] scsi: move unmap error checking to the complete callback Anton Nefedov
2018-02-07 15:00   ` [Qemu-devel] [Qemu-block] " Alberto Garcia
2018-01-19 12:50 ` [Qemu-devel] [PATCH v2 6/8] scsi: account unmap operations Anton Nefedov
2018-02-07 15:03   ` [Qemu-devel] [Qemu-block] " Alberto Garcia
2018-01-19 12:50 ` [Qemu-devel] [PATCH v2 7/8] file-posix: account discard operations Anton Nefedov
2018-02-07 15:10   ` [Qemu-devel] [Qemu-block] " Alberto Garcia
2018-02-12 16:19     ` Anton Nefedov
2018-02-16 11:36       ` Alberto Garcia
2018-01-19 12:50 ` [Qemu-devel] [PATCH v2 8/8] qapi: query-blockstat: add driver specific file-posix stats Anton Nefedov
2018-01-22 20:55   ` Eric Blake
2018-01-23 11:28     ` Anton Nefedov
2018-01-23 14:53       ` Eric Blake
2018-02-03 15:59     ` Markus Armbruster
2018-02-12 16:38       ` Anton Nefedov [this message]
2018-02-15 10:23         ` Anton Nefedov
2018-02-15 14:32           ` Eric Blake
2018-06-07 14:32       ` Anton Nefedov
2018-06-07 15:09         ` Markus Armbruster
2018-06-07 15:23           ` Anton Nefedov
2018-06-07 18:45             ` Eric Blake
2018-06-08  5:29               ` Markus Armbruster
2018-06-13 10:36                 ` Anton Nefedov
2018-06-13 11:40                   ` Markus Armbruster

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=8639a69c-ca85-d11b-7aaa-e67ffb660991@virtuozzo.com \
    --to=anton.nefedov@virtuozzo.com \
    --cc=armbru@redhat.com \
    --cc=den@virtuozzo.com \
    --cc=eblake@redhat.com \
    --cc=jsnow@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=pbonzini@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.