From: Max Reitz <mreitz@redhat.com>
To: Kevin Wolf <kwolf@redhat.com>, qemu-block@nongnu.org
Cc: jcody@redhat.com, berto@igalia.com, armbru@redhat.com,
stefanha@redhat.com, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 07/16] block: Convert bs->backing_hd to BdrvChild
Date: Tue, 22 Sep 2015 21:21:20 +0200 [thread overview]
Message-ID: <5601AA30.7020809@redhat.com> (raw)
In-Reply-To: <1442497700-2536-8-git-send-email-kwolf@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 4973 bytes --]
On 17.09.2015 15:48, Kevin Wolf wrote:
> This is the final step in converting all of the BlockDriverState
> pointers that block drivers use to BdrvChild.
>
> After this patch, bs->children contains the full list of child nodes
> that are referenced by a given BDS, and these children are only
> referenced through BdrvChild, so that updating the pointer in there is
> enough for changing edges in the graph.
>
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
> block.c | 116 +++++++++++++++++++++++++---------------------
> block/io.c | 24 +++++-----
> block/mirror.c | 7 +--
> block/qapi.c | 8 ++--
> block/qcow.c | 4 +-
> block/qcow2-cluster.c | 4 +-
> block/qcow2.c | 6 +--
> block/qed.c | 12 ++---
> block/stream.c | 10 ++--
> block/vmdk.c | 21 +++++----
> block/vvfat.c | 6 +--
> blockdev.c | 6 +--
> include/block/block_int.h | 12 +++--
> qemu-img.c | 8 ++--
> 14 files changed, 130 insertions(+), 114 deletions(-)
>
[...]
> diff --git a/block/io.c b/block/io.c
> index 8a27efa..d7e742a 100644
> --- a/block/io.c
> +++ b/block/io.c
[...]
> @@ -1604,7 +1604,7 @@ int64_t bdrv_get_block_status(BlockDriverState *bs,
> int64_t sector_num,
> int nb_sectors, int *pnum)
> {
> - return bdrv_get_block_status_above(bs, bs->backing_hd,
> + return bdrv_get_block_status_above(bs, backing_bs(bs),
> sector_num, nb_sectors, pnum);
> }
>
> @@ -1662,7 +1662,7 @@ int bdrv_is_allocated_above(BlockDriverState *top,
> n = pnum_inter;
> }
>
> - intermediate = intermediate->backing_hd;
> + intermediate = intermediate->backing ? intermediate->backing->bs : NULL;
backing_bs(intermediate)?
> }
>
> *pnum = n;
> diff --git a/block/mirror.c b/block/mirror.c
> index a258926..259e11a 100644
> --- a/block/mirror.c
> +++ b/block/mirror.c
> @@ -371,7 +371,8 @@ static void mirror_exit(BlockJob *job, void *opaque)
> if (s->common.driver->job_type == BLOCK_JOB_TYPE_COMMIT) {
> /* drop the bs loop chain formed by the swap: break the loop then
> * trigger the unref from the top one */
> - BlockDriverState *p = s->base->backing_hd;
> + BlockDriverState *p = s->base->backing
> + ? s->base->backing->bs : NULL;
Maybe you don't want to use backing_bs() outside of the core block
layer, but it could be used here, too.
(There are two similar expressions in block/stream.c, and maybe
elsewhere, too)
> bdrv_set_backing_hd(s->base, NULL);
> bdrv_unref(p);
> }
[...]
> diff --git a/blockdev.c b/blockdev.c
> index 32b04b4..bc158ff 100644
> --- a/blockdev.c
> +++ b/blockdev.c
> @@ -2508,10 +2508,10 @@ void qmp_drive_backup(const char *device, const char *target,
> /* See if we have a backing HD we can use to create our new image
> * on top of. */
> if (sync == MIRROR_SYNC_MODE_TOP) {
> - source = bs->backing_hd;
> - if (!source) {
> + if (!bs->backing) {
> sync = MIRROR_SYNC_MODE_FULL;
> }
> + source = bs->backing->bs;
That doesn't seem right. In case of !bs->backing, this won't abort but
just continue and run into bs->backing->bs, which should therefore
probably be backing_bs(bs) instead.
> }
> if (sync == MIRROR_SYNC_MODE_NONE) {
> source = bs;
> @@ -2716,7 +2716,7 @@ void qmp_drive_mirror(const char *device, const char *target,
> }
>
> flags = bs->open_flags | BDRV_O_RDWR;
> - source = bs->backing_hd;
> + source = bs->backing ? bs->backing->bs : NULL;
Why not source = backing_bs(bs)?
> if (!source && sync == MIRROR_SYNC_MODE_TOP) {
> sync = MIRROR_SYNC_MODE_FULL;
> }
[...]
> diff --git a/qemu-img.c b/qemu-img.c
> index 6ff4e85..c4454da 100644
> --- a/qemu-img.c
> +++ b/qemu-img.c
[...]
> @@ -2206,11 +2206,11 @@ static int get_block_status(BlockDriverState *bs, int64_t sector_num,
> if (ret & (BDRV_BLOCK_ZERO|BDRV_BLOCK_DATA)) {
> break;
> }
> - bs = bs->backing_hd;
> - if (bs == NULL) {
> + if (bs->backing == NULL) {
> ret = 0;
> break;
> }
> + bs = bs->backing->bs;
This changes behavior. bs needs to be set to NULL in the
if (bs->backing == NULL) block, or the break will break: Before, if
bs->backing_hd == NULL, the loop was left with bs == NULL. Now, bs won't
be NULL anymore (but its value is used after the loop and stored in e->bs).
Max
>
> depth++;
> }
>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]
next prev parent reply other threads:[~2015-09-22 19:21 UTC|newest]
Thread overview: 68+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-17 13:48 [Qemu-devel] [PATCH 00/16] block: Get rid of bdrv_swap() Kevin Wolf
2015-09-17 13:48 ` [Qemu-devel] [PATCH 01/16] block: Introduce BDS.file_child Kevin Wolf
2015-09-22 17:14 ` Max Reitz
2015-09-22 17:17 ` Max Reitz
2015-09-23 14:26 ` Alberto Garcia
2015-09-17 13:48 ` [Qemu-devel] [PATCH 02/16] vmdk: Use BdrvChild instead of BDS for references to extents Kevin Wolf
2015-09-22 17:45 ` Max Reitz
2015-09-23 13:23 ` Alberto Garcia
2015-09-17 13:48 ` [Qemu-devel] [PATCH 03/16] blkverify: Convert s->test_file to BdrvChild Kevin Wolf
2015-09-22 17:51 ` Max Reitz
2015-09-23 13:01 ` Alberto Garcia
2015-09-23 13:58 ` Kevin Wolf
2015-09-23 14:05 ` Alberto Garcia
2015-09-23 14:11 ` Alberto Garcia
2015-09-17 13:48 ` [Qemu-devel] [PATCH 04/16] quorum: Convert " Kevin Wolf
2015-09-22 17:57 ` Max Reitz
2015-09-23 12:48 ` Alberto Garcia
2015-09-17 13:48 ` [Qemu-devel] [PATCH 05/16] block: Convert bs->file " Kevin Wolf
2015-09-22 18:36 ` Max Reitz
2015-09-23 13:13 ` Kevin Wolf
2015-09-23 14:54 ` Alberto Garcia
2015-09-25 14:09 ` Alberto Garcia
2015-09-17 13:48 ` [Qemu-devel] [PATCH 06/16] block: Remove bdrv_open_image() Kevin Wolf
2015-09-22 18:38 ` Max Reitz
2015-09-23 13:10 ` Alberto Garcia
2015-09-17 13:48 ` [Qemu-devel] [PATCH 07/16] block: Convert bs->backing_hd to BdrvChild Kevin Wolf
2015-09-22 19:21 ` Max Reitz [this message]
2015-09-17 13:48 ` [Qemu-devel] [PATCH 08/16] block: Manage backing file references in bdrv_set_backing_hd() Kevin Wolf
2015-09-23 15:22 ` Max Reitz
2015-09-28 12:29 ` Alberto Garcia
2015-09-17 13:48 ` [Qemu-devel] [PATCH 09/16] block: Split bdrv_move_feature_fields() Kevin Wolf
2015-09-23 16:36 ` Max Reitz
2015-09-29 13:37 ` Kevin Wolf
2015-09-30 14:51 ` Max Reitz
2015-09-17 13:48 ` [Qemu-devel] [PATCH 10/16] block/io: Make bdrv_requests_pending() public Kevin Wolf
2015-09-23 15:40 ` Max Reitz
2015-09-29 12:29 ` Kevin Wolf
2015-09-28 12:32 ` Alberto Garcia
2015-09-17 13:48 ` [Qemu-devel] [PATCH 11/16] block-backend: Add blk_set_bs() Kevin Wolf
2015-09-23 15:46 ` Max Reitz
2015-09-23 15:51 ` Kevin Wolf
2015-09-17 13:48 ` [Qemu-devel] [PATCH 12/16] block: Introduce parents list Kevin Wolf
2015-09-23 16:39 ` Max Reitz
2015-09-28 13:09 ` Alberto Garcia
2015-09-29 12:21 ` Kevin Wolf
2015-09-29 14:00 ` Alberto Garcia
2015-09-17 13:48 ` [Qemu-devel] [PATCH 13/16] block: Implement bdrv_append() without bdrv_swap() Kevin Wolf
2015-09-18 11:45 ` Alberto Garcia
2015-09-18 12:24 ` Kevin Wolf
2015-09-18 13:31 ` Alberto Garcia
2015-09-18 14:23 ` Kevin Wolf
2015-09-23 16:36 ` Max Reitz
2015-09-29 13:51 ` Kevin Wolf
2015-09-30 14:45 ` Max Reitz
2015-09-30 15:33 ` Kevin Wolf
2015-09-17 13:48 ` [Qemu-devel] [PATCH 14/16] blockjob: Store device name at job creation Kevin Wolf
2015-09-23 16:46 ` Max Reitz
2015-09-17 13:48 ` [Qemu-devel] [PATCH 15/16] block: Add and use bdrv_replace_in_backing_chain() Kevin Wolf
2015-09-23 17:08 ` Max Reitz
2015-09-29 15:22 ` Kevin Wolf
2015-09-30 14:50 ` Max Reitz
2015-09-30 14:50 ` Max Reitz
2015-09-17 13:48 ` [Qemu-devel] [PATCH 16/16] block: Remove bdrv_swap() Kevin Wolf
2015-09-23 17:09 ` Max Reitz
2015-09-28 13:24 ` Alberto Garcia
2015-09-18 11:03 ` [Qemu-devel] [PATCH 00/16] block: Get rid of bdrv_swap() Alberto Garcia
2015-09-22 10:07 ` Kevin Wolf
2015-09-24 18:32 ` Alberto Garcia
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=5601AA30.7020809@redhat.com \
--to=mreitz@redhat.com \
--cc=armbru@redhat.com \
--cc=berto@igalia.com \
--cc=jcody@redhat.com \
--cc=kwolf@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/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.