Received: from eggs.gnu.org ([2001:4830:134:3::10]:56480) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bAecn-00019b-FG for qemu-devel@nongnu.org; Wed, 08 Jun 2016 10:38:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bAecm-0006XH-13 for qemu-devel@nongnu.org; Wed, 08 Jun 2016 10:38:29 -0400 References: <20160606144212.24074-1-mreitz@redhat.com> <20160606144212.24074-3-mreitz@redhat.com> <20160608093229.GC5324@noname.str.redhat.com> From: Max Reitz Message-ID: <32cb23d5-66ae-1ffc-ce5b-3c83fb80a434@redhat.com> Date: Wed, 8 Jun 2016 16:38:19 +0200 MIME-Version: 1.0 In-Reply-To: <20160608093229.GC5324@noname.str.redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="R5fPl0pER3Raq29IAPkswUkoKAUKgfmA7" Subject: Re: [Qemu-devel] [PATCH v2 2/3] block/mirror: Fix target backing BDS List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf Cc: qemu-block@nongnu.org, qemu-devel@nongnu.org, Fam Zheng , nsoffer@redhat.com, eblake@redhat.com, pbonzini@redhat.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --R5fPl0pER3Raq29IAPkswUkoKAUKgfmA7 From: Max Reitz To: Kevin Wolf Cc: qemu-block@nongnu.org, qemu-devel@nongnu.org, Fam Zheng , nsoffer@redhat.com, eblake@redhat.com, pbonzini@redhat.com Message-ID: <32cb23d5-66ae-1ffc-ce5b-3c83fb80a434@redhat.com> Subject: Re: [PATCH v2 2/3] block/mirror: Fix target backing BDS References: <20160606144212.24074-1-mreitz@redhat.com> <20160606144212.24074-3-mreitz@redhat.com> <20160608093229.GC5324@noname.str.redhat.com> In-Reply-To: <20160608093229.GC5324@noname.str.redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable On 08.06.2016 11:32, Kevin Wolf wrote: > Am 06.06.2016 um 16:42 hat Max Reitz geschrieben: >> Currently, we are trying to move the backing BDS from the source to th= e >> target in bdrv_replace_in_backing_chain() which is called from >> mirror_exit(). However, mirror_complete() already tries to open the >> target's backing chain with a call to bdrv_open_backing_file(). >> >> First, we should only set the target's backing BDS once. Second, the >> mirroring block job has a better idea of what to set it to than the >> generic code in bdrv_replace_in_backing_chain() (in fact, the latter's= >> conditions on when to move the backing BDS from source to target are n= ot >> really correct). >> >> Therefore, remove that code from bdrv_replace_in_backing_chain() and >> leave it to mirror_complete(). >> >> However, mirror_complete() in turn pursues a questionable strategy by >> employing bdrv_open_backing_file(): On the one hand, because this may >> open the wrong backing file with drive-mirror in "existing" mode, or >> because it will not override a possibly wrong backing file in the >> blockdev-mirror case. >> >> On the other hand, we want to reuse the existing backing chain of the >> source instead of opening everything anew, because the latter results = in >> having multiple BDSs for a single physical file and thus potentially >> concurrent access which we should try to avoid. >=20 > Careful, this "wrong" backing file might actually be intended! True. I still consider completely opening the backing chain not correct, though, at least in absolute-paths mode, because this will result in having at least two BDSs for single physical image files (once for the old chain, once for the new one). So let's go through everything. =3D=3D drive-mirror with absolute-paths =3D=3D We already have the backing chain open (around the source BDS), and it's definitely the correct one. So I think we can always reuse it for the target. =3D=3D drive-mirror with existing =3D=3D You're right, we should probably keep doing bdrv_open_backing_file() because we cannot check whether the existing image has the same backing chain as a new absolute-paths image would have had. This is prone to give you some issues if you actually do want to have the "default" backing chain, though, because of the multiple BDS thing. This case is basically guaranteed to break with sync=3Dnone and default image locking. =3D=3D blockdev-mirror =3D=3D In theory the simplest one: We just assume the backing chain of the target has been opened already, and then we blame the user if they have created multiple BDSs per physical file. Unluckily in practice, though, we require the target BDS to not have a backing file at all. blockdev-mirror is just supposed to open the backing chain after completion, which I really don't like (I don't think a blockdev- command should do this kind of magic). Maybe we should allow the target to have a backing file (I really don't see why it shouldn't have one) and treat the non-backing case like drive-mirror in existing mode. Does that sound right? Max > Consider a case where you want to move an image with its whole backing > chain to different storage. In that case, you would copy all of the > backing files (cp is good enough, they are read-only), create the > destination image which already points at the copied backing chain, and= > then mirror in "existing" mode. >=20 > The intention is obviously that after the job completion the new backin= g > chain is used and not the old one. >=20 > I know that such cases were discussed when mirroring was introduced, I'= m > not sure whether it's actually used. We need some input there: >=20 > Eric, can you tell us whether libvirt makes use of such a setup? >=20 > Nir, I'm not sure who is the right person in oVirt these days, but do > you either know yourself whether oVirt requires this to work, or do you= > know who else would know? >=20 >> Thus, instead of invoking bdrv_open_backing_file(), just set the corre= ct >> backing BDS directly via bdrv_set_backing_hd(). Also, do so only when >> mirror_complete() is certain to succeed. >> >> In contrast to what bdrv_replace_in_backing_chain() did so far, we do >> not need to drop the source's backing file. >> >> Signed-off-by: Max Reitz >=20 > Leaving the actual code review for later when we have decided what > semantics we even want. >=20 > Kevin >=20 --R5fPl0pER3Raq29IAPkswUkoKAUKgfmA7 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 iQEcBAEBCAAGBQJXWC3bAAoJEDuxQgLoOKyt1P4H/0scvvu6xUjUsrbQXYNWWqpM GiqZOhOBhMoBlaSeDOX8bFoSpOaUdryVUHn3oPsZ5luSrQ/fIS5GrOa4xB3tkemo 9vhEIHGZnIVCuWZGjaboN1/GBf/TuUGdbuZT1KjJNHfRBQUn/FXsRgzeKTYHS79s Ft9T6GsqGRMcn7WnUeLfNdXglVK5Lqp8a0Ohkka2JMYoRLNzIpOMsz42bS4mqroV c9r8akZzraGOISonoPVio1bb+c4+HcKO4+qDZcesyUSF3btmnzd9FZIm2CK+7TK3 kjMu23z3T38eEa4EnnJFCnwgVHy+Nj1i5tbwn0h3vcO/+oSBCfN2A/hE74J9gDI= =ytal -----END PGP SIGNATURE----- --R5fPl0pER3Raq29IAPkswUkoKAUKgfmA7--