qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: Max Reitz <mreitz@redhat.com>
Cc: qemu-block@nongnu.org, qemu-devel@nongnu.org,
	Fam Zheng <famz@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v2 1/3] block: Allow replacement of a BDS by its overlay
Date: Wed, 8 Jun 2016 10:58:35 +0200	[thread overview]
Message-ID: <20160608085835.GB5324@noname.str.redhat.com> (raw)
In-Reply-To: <20160606144212.24074-2-mreitz@redhat.com>

Am 06.06.2016 um 16:42 hat Max Reitz geschrieben:
> change_parent_backing_link() asserts that the BDS to be replaced is not
> used as a backing file. However, we may want to replace a BDS by its
> overlay in which case that very link should not be redirected.
> 
> Signed-off-by: Max Reitz <mreitz@redhat.com>

So the scenario is like this?

              +---- to
              v
    base <- from <- top

And we want to change it into this:

    base <- from <- to <- top

Okay, makes sense.

(Hm, put ASCII art in the commit message? I'd be all for it.)

>  block.c | 15 ++++++++++++++-
>  1 file changed, 14 insertions(+), 1 deletion(-)
> 
> diff --git a/block.c b/block.c
> index f54bc25..16463aa 100644
> --- a/block.c
> +++ b/block.c
> @@ -2224,9 +2224,22 @@ void bdrv_close_all(void)
>  static void change_parent_backing_link(BlockDriverState *from,
>                                         BlockDriverState *to)
>  {
> -    BdrvChild *c, *next;
> +    BdrvChild *c, *next, *to_c;
>  
>      QLIST_FOREACH_SAFE(c, &from->parents, next_parent, next) {
> +        if (c->role == &child_backing) {
> +            /* Allow @from to be in a backing chain, but only if it is @to's
> +             * backing chain. Do not replace @from by @to there. */

The comment suggests bdrv_chain_contains(), but you only accept it as a
direct child of top and you accept non-backing-file children.

Intuitively I would say that anywhere in the backing chain would make
sense, but we can always allow that later when we actually need it.
Accepting all types of children sounds right when I think about
inserting a quorum node as 'to'.

So I guess the code is fine and the comment should be changed to
correctly reflect what the code does.

> +            QLIST_FOREACH(to_c, &to->children, next) {
> +                if (to_c == c) {
> +                    break;
> +                }
> +            }
> +            if (to_c) {
> +                continue;
> +            }
> +        }
> +
>          assert(c->role != &child_backing);
>          bdrv_ref(to);
>          bdrv_replace_child(c, to);

The other thing is that I'm unsure whether this function makes any sense
at all. "Replace in all parents" is kind of arbitrary. In the long term,
we may want to allow the user to specify the exact graph modifications
on (block-)job-complete.

Kevin

  reply	other threads:[~2016-06-08  8:58 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-06 14:42 [Qemu-devel] [PATCH v2 0/3] block/mirror: Fix target backing BDS Max Reitz
2016-06-06 14:42 ` [Qemu-devel] [PATCH v2 1/3] block: Allow replacement of a BDS by its overlay Max Reitz
2016-06-08  8:58   ` Kevin Wolf [this message]
2016-06-08 14:21     ` Max Reitz
2016-06-06 14:42 ` [Qemu-devel] [PATCH v2 2/3] block/mirror: Fix target backing BDS Max Reitz
2016-06-08  9:32   ` Kevin Wolf
2016-06-08 11:28     ` Paolo Bonzini
2016-06-08 11:47       ` Kevin Wolf
2016-06-08 14:40       ` Max Reitz
2016-06-08 14:42         ` Max Reitz
2016-06-08 14:38     ` Max Reitz
2016-06-08 16:54       ` Max Reitz
2016-06-08 15:39     ` Nir Soffer
2016-06-09  8:58       ` Kevin Wolf
2016-06-09 11:16         ` Nir Soffer
2016-06-06 14:42 ` [Qemu-devel] [PATCH v2 3/3] iotests: Add test for post-mirror backing chains 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=20160608085835.GB5324@noname.str.redhat.com \
    --to=kwolf@redhat.com \
    --cc=famz@redhat.com \
    --cc=mreitz@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).