Received: from eggs.gnu.org ([2001:4830:134:3::10]:36851) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZhJO2-0004qe-QF for qemu-devel@nongnu.org; Wed, 30 Sep 2015 11:33:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZhJNy-0007es-Qg for qemu-devel@nongnu.org; Wed, 30 Sep 2015 11:33:42 -0400 Date: Wed, 30 Sep 2015 17:33:25 +0200 From: Kevin Wolf Message-ID: <20150930153325.GE3989@noname.str.redhat.com> References: <1442497700-2536-1-git-send-email-kwolf@redhat.com> <1442497700-2536-14-git-send-email-kwolf@redhat.com> <5602D522.5030905@redhat.com> <20150929135151.GK3930@noname.str.redhat.com> <560BF56D.9060201@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="BOKacYhQ+x31HxR3" Content-Disposition: inline In-Reply-To: <560BF56D.9060201@redhat.com> Subject: Re: [Qemu-devel] [PATCH 13/16] block: Implement bdrv_append() without bdrv_swap() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Max Reitz Cc: berto@igalia.com, qemu-block@nongnu.org, jcody@redhat.com, qemu-devel@nongnu.org, armbru@redhat.com, stefanha@redhat.com --BOKacYhQ+x31HxR3 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Am 30.09.2015 um 16:45 hat Max Reitz geschrieben: > On 29.09.2015 15:51, Kevin Wolf wrote: > > Am 23.09.2015 um 18:36 hat Max Reitz geschrieben: > >> On 17.09.2015 15:48, Kevin Wolf wrote: > >>> void bdrv_append(BlockDriverState *bs_new, BlockDriverState *bs_top) > >>> { > >>> - bdrv_swap(bs_new, bs_top); > >>> + assert(!bdrv_requests_pending(bs_top)); > >>> + assert(!bdrv_requests_pending(bs_new)); > >>> + > >>> + bdrv_ref(bs_top); > >>> + change_parent_backing_link(bs_top, bs_new); > >>> + > >>> + /* Some fields always stay on top of the backing file chain */ > >>> + swap_feature_fields(bs_top, bs_new); > >>> + > >>> + bdrv_set_backing_hd(bs_new, bs_top); > >>> + bdrv_unref(bs_top); > >>> =20 > >>> - /* The contents of 'tmp' will become bs_top, as we are > >>> - * swapping bs_new and bs_top contents. */ > >>> - bdrv_set_backing_hd(bs_top, bs_new); > >>> + /* bs_new is now referenced by its new parents, we don't need the > >>> + * additional reference any more. */ > >>> + bdrv_unref(bs_new); > >>> } > >> > >> Before, all pointers to @bs_new were moved to @bs_top. Now, they stay = at > >> @bs_new. I suppose we are assuming there are no pointers to @bs_new, > >> should we assert that, and/or point it out in the documentation? > >=20 > > How would you assert something like this? >=20 > Of course, I have no idea. >=20 > > Also, I think it's currently > > true, but there's no reason why it should stay so. The important part is > > just that it's true while applying the patch because the semantics > > changes. Once it's applied, we have sane behaviour and can make use of > > it. >=20 > The thing is that this is exactly the reason for the bug Berto found. > external_snapshot_commit() keeps a reference to state->new_bs (@bs_new) > and uses it afterwards for bdrv_reopen(), whereas it should be using > state->old_bs (@bs_top) after this series. Yes, the interface changes. That means that you need to review all callers. There aren't that many, so it's doable. Kevin --BOKacYhQ+x31HxR3 Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (GNU/Linux) iQIcBAEBAgAGBQJWDADFAAoJEH8JsnLIjy/W1yMP/0PiU2Cs+9fW+zmbDnHwqB/g D0T/MPHFhc/t0mVXCqzqUg3+R+ZlnXBtyJ8dnZ4xfrPlgPPg9iRp+EIBIhRKZ/st biGBXTjJ1/YRc18IAbXthf0X0QqHGQ3QzYRsFb7Z63Q+Ava8giOqE2ogUEVUdPo7 IpEd8OQm3PaXfptjd3UZ6BZc3IQzk1wOCw8Hd+PJoR0iaBLO31d5plvcYsk7CiaR 5YuL2eCCh2U45RnWkxjszLIsS9T5CKgfmkMPxbJjCipNbeWsV+Y7txl8iTscbPa0 bk44FgmK37O1Px5S177id9smjztuq/iZwquy5EnocNmkfDoE4InAFryGX8gLiqBb fipxg+6LJ/uF+dhNLFfbgUfCmRykDTeXzCVix/rL8Y9p0LTTa8FjVoJvXbUH7XbM G4lNyFL3rxGOSIxLMk7ZsX8TlK1SPWCrhyENKZuZR7W1cOYfeRTllSJlMCtJ7FRs gNtGP3qiI4WM71d4xYxzx9TQ4S6LQqdGOrgc9qdkTVevl5ZFPRS6ts6g5jHhW0M8 ITuaJMHWOiiVz04wgmkETCfbIYhiY90J72YMgwxXAfSiK7FoeVItoJh+bSQC6Gx1 Nf+DWmbLvBWI/PoeNIuwONxBVcJe7mJzXSMw3z3yFh7lrGwa1JSlELczqdRo9a3E I1kvIbd4qwP2NB5Zsp/5 =IxV9 -----END PGP SIGNATURE----- --BOKacYhQ+x31HxR3--