From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46916) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeT88-0002Wg-L0 for qemu-devel@nongnu.org; Tue, 22 Sep 2015 15:21:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZeT87-00056K-Lb for qemu-devel@nongnu.org; Tue, 22 Sep 2015 15:21:32 -0400 References: <1442497700-2536-1-git-send-email-kwolf@redhat.com> <1442497700-2536-8-git-send-email-kwolf@redhat.com> From: Max Reitz Message-ID: <5601AA30.7020809@redhat.com> Date: Tue, 22 Sep 2015 21:21:20 +0200 MIME-Version: 1.0 In-Reply-To: <1442497700-2536-8-git-send-email-kwolf@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="eG9JITQrLrOxRoQOvdHGblgHRF5e7Nc8v" Subject: Re: [Qemu-devel] [PATCH 07/16] block: Convert bs->backing_hd to BdrvChild List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf , qemu-block@nongnu.org Cc: jcody@redhat.com, berto@igalia.com, armbru@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --eG9JITQrLrOxRoQOvdHGblgHRF5e7Nc8v Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: quoted-printable 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. >=20 > 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. >=20 > Signed-off-by: Kevin Wolf > --- > 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(-) >=20 [...] > 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 *b= s, > 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); > } > =20 > @@ -1662,7 +1662,7 @@ int bdrv_is_allocated_above(BlockDriverState *top= , > n =3D pnum_inter; > } > =20 > - intermediate =3D intermediate->backing_hd; > + intermediate =3D intermediate->backing ? intermediate->backing= ->bs : NULL; backing_bs(intermediate)? > } > =20 > *pnum =3D 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 =3D=3D BLOCK_JOB_TYPE_COMMIT) {= > /* drop the bs loop chain formed by the swap: break the lo= op then > * trigger the unref from the top one */ > - BlockDriverState *p =3D s->base->backing_hd; > + BlockDriverState *p =3D 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 =3D=3D MIRROR_SYNC_MODE_TOP) { > - source =3D bs->backing_hd; > - if (!source) { > + if (!bs->backing) { > sync =3D MIRROR_SYNC_MODE_FULL; > } > + source =3D 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 =3D=3D MIRROR_SYNC_MODE_NONE) { > source =3D bs; > @@ -2716,7 +2716,7 @@ void qmp_drive_mirror(const char *device, const c= har *target, > } > =20 > flags =3D bs->open_flags | BDRV_O_RDWR; > - source =3D bs->backing_hd; > + source =3D bs->backing ? bs->backing->bs : NULL; Why not source =3D backing_bs(bs)? > if (!source && sync =3D=3D MIRROR_SYNC_MODE_TOP) { > sync =3D 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 *b= s, int64_t sector_num, > if (ret & (BDRV_BLOCK_ZERO|BDRV_BLOCK_DATA)) { > break; > } > - bs =3D bs->backing_hd; > - if (bs =3D=3D NULL) { > + if (bs->backing =3D=3D NULL) { > ret =3D 0; > break; > } > + bs =3D bs->backing->bs; This changes behavior. bs needs to be set to NULL in the if (bs->backing =3D=3D NULL) block, or the break will break: Before, if bs->backing_hd =3D=3D NULL, the loop was left with bs =3D=3D NULL. Now, b= s won't be NULL anymore (but its value is used after the loop and stored in e->bs= ). Max > =20 > depth++; > } >=20 --eG9JITQrLrOxRoQOvdHGblgHRF5e7Nc8v Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJWAaowAAoJEDuxQgLoOKyt0fAIAKIN8kQlTrpPM+1X3dqm3s/I NrbqYFdj0IbSNpWO3T2JpxJeJ3MkNqaWfRvXh/zdsk8Xnw65yKA/kAp414vQdMIa 1swjNrGBK7moOOELa6QHGOFvVYxnm3LOsYCAr5U5Q/ppcm6xOo8o9bTKvuyGgu7g 2QsD5uIC/mVXbBQWoh5WJ/+Qbu16gBBCqzMAMz+fExLZTDGkm1p8CZMAGsqa1xaY AXFehwISmtdIrM3HchUDeIdD4BAVGzKTMKBLg0gjsKclDLsKYKNZgobquzZ1bU5A OV9OwLU6b4FixsemkaP4y3G1wR8bKbv0vI5LUkOxNvC6pzB1c2ayC3NSujgS0pE= =7Wgl -----END PGP SIGNATURE----- --eG9JITQrLrOxRoQOvdHGblgHRF5e7Nc8v--