qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: Jeff Cody <jcody@redhat.com>
Cc: pbonzini@redhat.com, eblake@redhat.com, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v2 1/7] block: add support functions for live commit, to find and delete images.
Date: Wed, 26 Sep 2012 15:53:27 +0200	[thread overview]
Message-ID: <506308D7.6080209@redhat.com> (raw)
In-Reply-To: <75d3d050da8a4b3cee36d8c3c6dbf67014b7db6c.1348589526.git.jcody@redhat.com>

Am 25.09.2012 18:29, schrieb Jeff Cody:
> Add bdrv_find_overlay(), and bdrv_drop_intermediate().
> 
> bdrv_find_overlay():  given 'bs' and the active (topmost) BDS of an image chain,
>                     find the image that is the immediate top of 'bs'
> 
> bdrv_drop_intermediate():
>                     Given 3 BDS (active, top, base), drop images above
>                     base up to and including top, and set base to be the
>                     backing file of top's overlay node.
> 
>                     E.g., this converts:
> 
>                     bottom <- base <- intermediate <- top <- active
> 
>                     to
> 
>                     bottom <- base <- active
> 
> Signed-off-by: Jeff Cody <jcody@redhat.com>

> +/*
> + * Drops images above 'base' up to and including 'top', and sets the image
> + * above 'top' to have base as its backing file.
> + *
> + * Requires that the overlay to 'top' is opened r/w, so that the backing file
> + * information in 'bs' can be properly updated.
> + *
> + * E.g., this will convert the following chain:
> + * bottom <- base <- intermediate <- top <- active
> + *
> + * to
> + *
> + * bottom <- base <- active
> + *
> + * It is allowed for bottom==base, in which case it converts:
> + *
> + * base <- intermediate <- top <- active
> + *
> + * to
> + *
> + * base <- active

Compared to RFC v2 you deleted this part of the comment:

  + *
  + * It is also allowed for top==active, except in that case active is not
  + * deleted:

You describe the condition now as an error (which I think is what our
conclusion on IRC was), but now I think the following example must be
removed as well:

> + *
> + * base <- intermediate <- top
> + *
> + * becomes
> + *
> + * base <- top
> + *
> + * Error conditions:
> + *  if active == top, that is considered an error
> + *
> + */
> +int bdrv_drop_intermediate(BlockDriverState *active, BlockDriverState *top,
> +                           BlockDriverState *base)
> +{
> +    BlockDriverState *intermediate;
> +    BlockDriverState *base_bs = NULL;
> +    BlockDriverState *new_top_bs = NULL;
> +    BlkIntermediateStates *intermediate_state, *next;
> +    int ret = -EIO;
> +
> +    QSIMPLEQ_HEAD(states_to_delete, BlkIntermediateStates) states_to_delete;
> +    QSIMPLEQ_INIT(&states_to_delete);
> +
> +    if (!top->drv || !base->drv) {
> +        goto exit;
> +    }
> +
> +    new_top_bs = bdrv_find_overlay(active, top);
> +
> +    if (new_top_bs == NULL) {
> +        /* we could not find the image above 'top', this is an error */
> +        goto exit;
> +    }
> +
> +    /* special case of new_top_bs->backing_hd already pointing to base - nothing
> +     * to do, no intermediate images */
> +    if (new_top_bs->backing_hd == base) {
> +        ret = 0;
> +        goto exit;
> +    }
> +
> +    intermediate = new_top_bs->backing_hd;  /* this should be the same
> +                                               as 'top' */

Should? Is it the same or not? If yes, you can write it as an assert();
it no, the comment is only confusing.

(In fact it's obvious enough that I'd just go with intermediate = top;
without any comment)

Kevin

  reply	other threads:[~2012-09-26 13:53 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-25 16:29 [Qemu-devel] [PATCH v2 0/7] Live block commit Jeff Cody
2012-09-25 16:29 ` [Qemu-devel] [PATCH v2 1/7] block: add support functions for live commit, to find and delete images Jeff Cody
2012-09-26 13:53   ` Kevin Wolf [this message]
2012-09-25 16:29 ` [Qemu-devel] [PATCH v2 2/7] block: add live block commit functionality Jeff Cody
2012-09-25 18:12   ` Eric Blake
2012-09-25 18:58     ` Jeff Cody
2012-09-25 19:05       ` Eric Blake
2012-09-26 14:03   ` Kevin Wolf
2012-09-25 16:29 ` [Qemu-devel] [PATCH v2 3/7] blockdev: rename block_stream_cb to a generic block_job_cb Jeff Cody
2012-09-25 16:29 ` [Qemu-devel] [PATCH v2 4/7] block: helper function, to find the base image of a chain Jeff Cody
2012-09-25 19:13   ` Eric Blake
2012-09-25 19:45     ` Jeff Cody
2012-09-25 16:29 ` [Qemu-devel] [PATCH v2 5/7] QAPI: add command for live block commit, 'block-commit' Jeff Cody
2012-09-25 19:42   ` Eric Blake
2012-09-25 19:57     ` Jeff Cody
2012-09-26 14:13   ` Kevin Wolf
2012-09-26 14:25     ` Jeff Cody
2012-09-26 14:33       ` Kevin Wolf
2012-09-26 14:34       ` Eric Blake
2012-09-25 16:29 ` [Qemu-devel] [PATCH v2 6/7] qemu-iotests: add initial tests for live block commit Jeff Cody
2012-09-25 18:02   ` Eric Blake
2012-09-25 18:53     ` Jeff Cody
2012-09-25 16:29 ` [Qemu-devel] [PATCH v2 7/7] block: after creating a live snapshot, make old image read-only Jeff Cody
2012-09-26 14:20   ` Kevin Wolf
2012-09-26 14:21     ` Jeff Cody

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=506308D7.6080209@redhat.com \
    --to=kwolf@redhat.com \
    --cc=eblake@redhat.com \
    --cc=jcody@redhat.com \
    --cc=pbonzini@redhat.com \
    --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).