All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Max Reitz <mreitz@redhat.com>, qemu-block@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v2 04/11] block: Storage child access function
Date: Mon, 12 Nov 2018 16:32:21 -0600	[thread overview]
Message-ID: <8022d6f6-46b7-cc9d-fafc-6f1c95bbd45b@redhat.com> (raw)
In-Reply-To: <20180809223117.7846-5-mreitz@redhat.com>

On 8/9/18 5:31 PM, Max Reitz wrote:
> For completeness' sake, add a function for accessing a node's storage
> child, too.  For filters, this is there filtered child; for non-filters,

s/there/their/

> this is bs->file.
> 
> Some places are deliberately left unconverted:
> - BDS opening/closing functions where bs->file is handled specially
>    (which is basically wrong, but at least simplifies probing)
> - bdrv_co_block_status_from_file(), because its name implies that it
>    points to ->file

I'm wondering if we can clean up block_status to let filters have a NULL 
callback and io.c do the right thing automatically, rather than the 
current approach of filters assigning the callback to the common helper 
routine.  Maybe later in the series.

> - bdrv_snapshot_goto() in one places unrefs bs->file.  Such a

s/places/place/

>    modification is not covered by this patch and is therefore just
>    safeguarded by an additional assert(), but otherwise kept as-is.
> 
> Signed-off-by: Max Reitz <mreitz@redhat.com>
> ---

> +++ b/block/snapshot.c

> @@ -204,37 +207,38 @@ int bdrv_snapshot_goto(BlockDriverState *bs,
>           return ret;
>       }
>   
> -    if (bs->file) {
> -        BlockDriverState *file;
> +    storage_bs = bdrv_storage_bs(bs);
> +    if (storage_bs) {
>           QDict *options = qdict_clone_shallow(bs->options);
>           QDict *file_options;
>           Error *local_err = NULL;
>   
> -        file = bs->file->bs;
>           /* Prevent it from getting deleted when detached from bs */
> -        bdrv_ref(file);
> +        bdrv_ref(storage_bs);
>   
>           qdict_extract_subqdict(options, &file_options, "file.");
>           qobject_unref(file_options);
> -        qdict_put_str(options, "file", bdrv_get_node_name(file));
> +        qdict_put_str(options, "file", bdrv_get_node_name(storage_bs));
>   
>           drv->bdrv_close(bs);
> +
> +        assert(bs->file->bs == storage_bs);

At first glance, this assertion...

>           bdrv_unref_child(bs, bs->file);
>           bs->file = NULL;
>   
> -        ret = bdrv_snapshot_goto(file, snapshot_id, errp);
> +        ret = bdrv_snapshot_goto(storage_bs, snapshot_id, errp);
>           open_ret = drv->bdrv_open(bs, options, bs->open_flags, &local_err);
>           qobject_unref(options);
>           if (open_ret < 0) {
> -            bdrv_unref(file);
> +            bdrv_unref(storage_bs);
>               bs->drv = NULL;
>               /* A bdrv_snapshot_goto() error takes precedence */
>               error_propagate(errp, local_err);
>               return ret < 0 ? ret : open_ret;
>           }
>   
> -        assert(bs->file->bs == file);
> -        bdrv_unref(file);
> +        assert(bs->file->bs == storage_bs);

...looks like a duplicate of this one. But looking closer, I see 
bs->file = NULL followed by drv->bdrv_open() in between which should 
reassign bs->file, so having the assertion on both ends makes sense.

Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org

  reply	other threads:[~2018-11-12 22:32 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-09 22:31 [Qemu-devel] [PATCH v2 00/11] block: Deal with filters Max Reitz
2018-08-09 22:31 ` [Qemu-devel] [PATCH v2 01/11] block: Mark commit and mirror as filter drivers Max Reitz
2018-09-07 12:37   ` [Qemu-devel] [Qemu-block] " Alberto Garcia
2018-08-09 22:31 ` [Qemu-devel] [PATCH v2 02/11] blockdev: Check @replaces in blockdev_mirror_common Max Reitz
2018-11-09 22:51   ` Eric Blake
2018-08-09 22:31 ` [Qemu-devel] [PATCH v2 03/11] block: Filtered children access functions Max Reitz
2018-11-12 22:17   ` Eric Blake
2018-11-14 19:52     ` Max Reitz
2019-02-13 16:42       ` Max Reitz
2018-08-09 22:31 ` [Qemu-devel] [PATCH v2 04/11] block: Storage child access function Max Reitz
2018-11-12 22:32   ` Eric Blake [this message]
2018-11-14 19:56     ` Max Reitz
2018-08-09 22:31 ` [Qemu-devel] [PATCH v2 05/11] block: Fix check_to_replace_node() Max Reitz
2018-11-12 22:47   ` [Qemu-devel] [for 3.1? Qemu-devel] " Eric Blake
2018-08-09 22:31 ` [Qemu-devel] [PATCH v2 06/11] iotests: Add tests for mirror @replaces loops Max Reitz
2018-08-09 22:47   ` Max Reitz
2018-11-12 22:54   ` Eric Blake
2018-08-09 22:31 ` [Qemu-devel] [PATCH v2 07/11] block: Leave BDS.backing_file constant Max Reitz
2018-11-12 23:08   ` Eric Blake
2018-11-14 20:01     ` Max Reitz
2018-08-09 22:31 ` [Qemu-devel] [PATCH v2 08/11] iotests: Add filter commit test cases Max Reitz
2018-08-09 22:31 ` [Qemu-devel] [PATCH v2 09/11] iotests: Add filter mirror " Max Reitz
2018-08-09 22:31 ` [Qemu-devel] [PATCH v2 10/11] iotests: Add test for commit in sub directory Max Reitz
2018-08-09 22:31 ` [Qemu-devel] [PATCH v2 11/11] iotests: Test committing to overridden backing Max Reitz
2018-08-09 22:33 ` [Qemu-devel] [PATCH v2 00/11] block: Deal with filters Max Reitz
2018-08-29 13:29 ` Max Reitz
2018-11-09 22:47 ` Eric Blake

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=8022d6f6-46b7-cc9d-fafc-6f1c95bbd45b@redhat.com \
    --to=eblake@redhat.com \
    --cc=kwolf@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 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.