qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Max Reitz <mreitz@redhat.com>
To: Kevin Wolf <kwolf@redhat.com>
Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org
Subject: Re: [PATCH for-5.0 02/31] block: Add BdrvChildRole
Date: Thu, 28 Nov 2019 17:36:50 +0100	[thread overview]
Message-ID: <42032cd8-c3ed-2eaa-3f11-306f9c16f5f1@redhat.com> (raw)
In-Reply-To: <20191128141218.GA4944@linux.fritz.box>


[-- Attachment #1.1: Type: text/plain, Size: 4797 bytes --]

On 28.11.19 15:12, Kevin Wolf wrote:
> Am 27.11.2019 um 14:15 hat Max Reitz geschrieben:
>> This enum will supplement BdrvChildClass when it comes to what role (or
>> combination of roles) a child takes for its parent.
>>
>> Because empty enums are not allowed, let us just start with it filled.
>>
>> Signed-off-by: Max Reitz <mreitz@redhat.com>
>> ---
>>  include/block/block.h | 38 ++++++++++++++++++++++++++++++++++++++
>>  1 file changed, 38 insertions(+)
>>
>> diff --git a/include/block/block.h b/include/block/block.h
>> index 38963ef203..36817d5689 100644
>> --- a/include/block/block.h
>> +++ b/include/block/block.h
>> @@ -279,6 +279,44 @@ enum {
>>      DEFAULT_PERM_UNCHANGED      = BLK_PERM_ALL & ~DEFAULT_PERM_PASSTHROUGH,
>>  };
>>  
>> +typedef enum BdrvChildRole {
>> +    /*
>> +     * If present, bdrv_replace_node() will not change the node this
>> +     * BdrvChild points to.
>> +     */
>> +    BDRV_CHILD_STAY_AT_NODE = (1 << 0),
>> +
>> +    /* Child stores data */
>> +    BDRV_CHILD_DATA         = (1 << 1),
>> +
>> +    /* Child stores metadata */
>> +    BDRV_CHILD_METADATA     = (1 << 2),
>> +
>> +    /* Filtered child */
>> +    BDRV_CHILD_FILTERED     = (1 << 3),
>> +
>> +    /* Child to COW from (backing child) */
>> +    BDRV_CHILD_COW          = (1 << 4),
>> +
>> +    /* Child is expected to be a protocol node */
>> +    BDRV_CHILD_PROTOCOL     = (1 << 5),
>> +
>> +    /* Child is expected to be a format node */
>> +    BDRV_CHILD_FORMAT       = (1 << 6),
> 
> In theory, a node shouldn't care what other nodes it has as its
> children. For a parent, protocols and formats look exactly the same.
> 
> Of course, we do have BDRV_O_PROTOCOL, but if I'm not mistaken this is
> basically only about probing or not probing an image format when a
> legacy filename is given rather than BlockdevOptions.
> 
> Therefore, unless you have a real reason for this to be here, I'd prefer
> if we could keep such legacy flags outside of the core infrastructure if
> at all possible.

Hm.  The reason I have it here is because currently this is handled by
BdrvChildClass.inherit_options.  For filtered and backing children, that
will leave PROTOCOL as it is; for the file child of format nodes it will
set PROTOCOL; and for some children (blkverify and quorum) it will clear
PROTOCOL.

So without these flags here, we can’t unify child_file, child_format,
and child_backing in a single class, just because they bequeath the
PROTOCOL flag differently.  At least not directly.

(I’d like to note that this doesn’t make anything worse.  Right now,
drivers need to make a conscious choice on this flag, too, namely by
choosing the right BdrvChildClass.)

Hmm.  Can we do better?  Instead of the driver hinting at what they
expect from the child, can we somehow infer that automatically in
block.c (i.e., in inherit_options without it being given PROTOCOL or
FORMAT)?  FILTERED || COW always means keeping it as-is.  METADATA
generally means setting PROTOCOL, I suppose.

The two problems that come to my mind are blkverify and quorum.
blkverify is special: It must enforce format-probing on the test image,
and it must disable format-probing on the verification (the raw) image.

Quorum wants format probing on everything, but all its children are
simply DATA children.  Other DATA children are e.g. external data files
of qcow2, and we certainly want to force-disable format probing there.

I suppose for the quorum problem we could introduce a
BlockDriver.is_format flag that would force O_PROTOCOL for all non-COW
children, but we would unset O_PROTOCOL for DATA children of
non-is_format drivers.

I suppose the same could work for blkverify’s test image.  For its raw
image, we’d probably just have to enforce the raw driver (or rely on the
fact that blkverify is technically a protocol driver in a way (it
implements .bdrv_file_open...), so it will always have O_PROTOCOL set on
itself; thus, its filtered child (the raw child) will automatically have
it, too, as long as we don’t touch it).

Do you have a better idea?

>> +    /*
>> +     * The primary child.  For most drivers, this is the child whose
>> +     * filename applies best to the parent node.
>> +     */
>> +    BDRV_CHILD_PRIMARY      = (1 << 7),
> 
> If primary is a flag of each BdrvChild, then you could end up having
> multiple children that claim that they're the primary child. On the
> other hand, if we have a bs->primary_child instead to make sure that we
> only have one primary child, we'd have to keep this consistent when
> children change.
> 
> So maybe just document that this flag must be given to only one
> BdrvChild link for each parent.

Sure.

Max


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

  reply	other threads:[~2019-11-28 16:58 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-27 13:15 [PATCH for-5.0 00/31] block: Introduce real BdrvChildRole Max Reitz
2019-11-27 13:15 ` [PATCH for-5.0 01/31] block: Rename BdrvChildRole to BdrvChildClass Max Reitz
2019-11-27 13:15 ` [PATCH for-5.0 02/31] block: Add BdrvChildRole Max Reitz
2019-11-28  9:31   ` Vladimir Sementsov-Ogievskiy
2019-11-28 10:52     ` Max Reitz
2019-11-28 11:24       ` Vladimir Sementsov-Ogievskiy
2019-11-28 14:00         ` Max Reitz
2019-11-28 14:12   ` Kevin Wolf
2019-11-28 16:36     ` Max Reitz [this message]
2019-11-27 13:15 ` [PATCH for-5.0 03/31] block: Add BdrvChildRole to BdrvChild Max Reitz
2019-11-27 13:15 ` [PATCH for-5.0 04/31] block: Pass BdrvChildRole to bdrv_child_perm() Max Reitz
2019-11-27 13:15 ` [PATCH for-5.0 05/31] block: Drop BdrvChildClass.stay_at_node Max Reitz
2019-11-27 13:15 ` [PATCH for-5.0 06/31] block: Keep BDRV_O_NO_IO in *inherited_fmt_options Max Reitz
2019-11-27 13:16 ` [PATCH for-5.0 07/31] block: Pass BdrvChildRole to .inherit_options() Max Reitz
2019-11-27 13:16 ` [PATCH for-5.0 08/31] block: Unify bdrv_*inherited_options() Max Reitz
2019-11-27 13:16 ` [PATCH for-5.0 09/31] block: Unify bdrv_child_cb_attach() Max Reitz
2019-11-27 13:16 ` [PATCH for-5.0 10/31] block: Unify bdrv_child_cb_detach() Max Reitz
2019-11-27 13:16 ` [PATCH for-5.0 11/31] block: Add child_of_bds Max Reitz
2019-11-27 13:16 ` [PATCH for-5.0 12/31] block: Distinguish paths in *_format_default_perms Max Reitz
2019-11-27 13:16 ` [PATCH for-5.0 13/31] block: Pull out bdrv_default_perms_for_backing() Max Reitz
2019-11-27 13:16 ` [PATCH for-5.0 14/31] block: Pull out bdrv_default_perms_for_storage() Max Reitz
2019-11-27 13:16 ` [PATCH for-5.0 15/31] block: Split bdrv_default_perms_for_storage() Max Reitz
2019-11-27 13:16 ` [PATCH for-5.0 16/31] block: Add bdrv_default_perms() Max Reitz
2019-11-27 13:16 ` [PATCH for-5.0 17/31] raw-format: Split raw_read_options() Max Reitz
2019-11-27 13:16 ` [PATCH for-5.0 18/31] block: Switch child_format users to child_of_bds Max Reitz
2019-11-27 13:16 ` [PATCH for-5.0 19/31] block: Drop child_format Max Reitz
2019-11-27 13:16 ` [PATCH for-5.0 20/31] block: Make backing files child_of_bds children Max Reitz
2019-11-27 13:16 ` [PATCH for-5.0 21/31] block: Drop child_backing Max Reitz
2019-11-27 13:16 ` [PATCH for-5.0 22/31] block: Make format drivers use child_of_bds Max Reitz
2019-11-27 13:16 ` [PATCH for-5.0 23/31] block: Make filter " Max Reitz
2019-11-27 13:16 ` [PATCH for-5.0 24/31] block: Use child_of_bds in remaining places Max Reitz
2019-11-27 13:16 ` [PATCH for-5.0 25/31] tests: Use child_of_bds instead of child_file Max Reitz
2019-11-27 13:16 ` [PATCH for-5.0 26/31] block: Use bdrv_default_perms() Max Reitz
2019-11-27 13:16 ` [PATCH for-5.0 27/31] block: Make bdrv_filter_default_perms() static Max Reitz
2019-11-27 13:16 ` [PATCH for-5.0 28/31] block: Drop bdrv_format_default_perms() Max Reitz
2019-11-27 13:16 ` [PATCH for-5.0 29/31] block: Drop child_file Max Reitz
2019-11-27 13:16 ` [PATCH for-5.0 30/31] block: Pass BdrvChildRole in remaining cases Max Reitz
2019-11-27 13:16 ` [PATCH for-5.0 31/31] block: Drop @child_class from bdrv_child_perm() 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=42032cd8-c3ed-2eaa-3f11-306f9c16f5f1@redhat.com \
    --to=mreitz@redhat.com \
    --cc=kwolf@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 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).