From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55743) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zen2X-0002im-Fe for qemu-devel@nongnu.org; Wed, 23 Sep 2015 12:37:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zen2W-0000hS-HU for qemu-devel@nongnu.org; Wed, 23 Sep 2015 12:37:05 -0400 References: <1442497700-2536-1-git-send-email-kwolf@redhat.com> <1442497700-2536-10-git-send-email-kwolf@redhat.com> From: Max Reitz Message-ID: <5602D520.3050303@redhat.com> Date: Wed, 23 Sep 2015 18:36:48 +0200 MIME-Version: 1.0 In-Reply-To: <1442497700-2536-10-git-send-email-kwolf@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="aMl8xfrvU8DQKOWPFlTcNOTbCDNdjps59" Subject: Re: [Qemu-devel] [PATCH 09/16] block: Split bdrv_move_feature_fields() 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) --aMl8xfrvU8DQKOWPFlTcNOTbCDNdjps59 Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: quoted-printable On 17.09.2015 15:48, Kevin Wolf wrote: > After bdrv_swap(), some fields must be moved back to their original BDS= > to compensate for the effects that a swap of the contents of the object= s > has while keeping the old addresses. Other fields must be moved back > because they should logically be moved and must stay on top >=20 > When replacing bdrv_swap() with operations changing the pointers in the= > parents, we only need the latter and must avoid swapping the former. > Split the function accordingly. >=20 > Signed-off-by: Kevin Wolf > --- > block.c | 12 ++++++++++++ > 1 file changed, 12 insertions(+) >=20 > diff --git a/block.c b/block.c > index 743f82e..7930f3c 100644 > --- a/block.c > +++ b/block.c > @@ -1984,6 +1984,8 @@ static void bdrv_rebind(BlockDriverState *bs) > } > } > =20 > +/* Fields that need to stay with the top-level BDS, no matter whether = the > + * address of the top-level BDS stays the same or not. */ > static void bdrv_move_feature_fields(BlockDriverState *bs_dest, > BlockDriverState *bs_src) > { > @@ -2019,7 +2021,13 @@ static void bdrv_move_feature_fields(BlockDriver= State *bs_dest, > =20 > /* dirty bitmap */ > bs_dest->dirty_bitmaps =3D bs_src->dirty_bitmaps; > +} > =20 > +/* Fields that only need to be swapped if the contents of BDSes is swa= pped > + * rather than pointers being changed in the parents. */ > +static void bdrv_move_reference_fields(BlockDriverState *bs_dest, > + BlockDriverState *bs_src) > +{ > /* reference count */ > bs_dest->refcnt =3D bs_src->refcnt; > =20 I'm not sure whether the op blockers should be moved in this function... I think they should be moved in bdrv_move_feasture_fields(), because they generally depend on the position within the node graph and not on the BDS itself, don't they? Max > @@ -2090,6 +2098,10 @@ void bdrv_swap(BlockDriverState *bs_new, BlockDr= iverState *bs_old) > bdrv_move_feature_fields(bs_old, bs_new); > bdrv_move_feature_fields(bs_new, &tmp); > =20 > + bdrv_move_reference_fields(&tmp, bs_old); > + bdrv_move_reference_fields(bs_old, bs_new); > + bdrv_move_reference_fields(bs_new, &tmp); > + > /* bs_new must remain unattached */ > assert(!bs_new->blk); > =20 >=20 --aMl8xfrvU8DQKOWPFlTcNOTbCDNdjps59 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 iQEbBAEBCAAGBQJWAtUgAAoJEDuxQgLoOKyt0tEH92eIghCJGsHvPBx3mCJqSMVP Y7o82dx4coQn4kXnv9utE4cRVlJsXE1v8t9hG82vMfNBhJxwrV6X+ziqGKQMyrFK SJrK6WO/0bAAARGfvlo1T+S0o+E4qBeDh5ZHflD9XjoVXZT9a10IyR6Hqgz+7GMs AF6iF2fcPxs+6FazzPOOhjYxhz0JmNhBJ7S1DGlXfPsn5wjy6EwqZ6A3FrSjV1oq JGl/D1QW0LY8NCtiIvaZEvLbh2yTB10pPNms7pSJM1aQYMMPtOpSgCIuh8fMybqQ qq8iqg8ZeNSsFT2Tjm2to8ovwfxlihfQArJudhU+MyEPtYQN1yx9AvYbxax/rA== =Tzrp -----END PGP SIGNATURE----- --aMl8xfrvU8DQKOWPFlTcNOTbCDNdjps59--