Received: from eggs.gnu.org ([2001:4830:134:3::10]:42076) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bAgka-0003rr-P5 for qemu-devel@nongnu.org; Wed, 08 Jun 2016 12:54:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bAgkY-0002eM-Gz for qemu-devel@nongnu.org; Wed, 08 Jun 2016 12:54:39 -0400 References: <20160606144212.24074-1-mreitz@redhat.com> <20160606144212.24074-3-mreitz@redhat.com> <20160608093229.GC5324@noname.str.redhat.com> <32cb23d5-66ae-1ffc-ce5b-3c83fb80a434@redhat.com> From: Max Reitz Message-ID: <1aa1c59d-5f40-5b99-62ec-dd9cf579300a@redhat.com> Date: Wed, 8 Jun 2016 18:54:27 +0200 MIME-Version: 1.0 In-Reply-To: <32cb23d5-66ae-1ffc-ce5b-3c83fb80a434@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="5X4CtbiKQrrVmcBjTKHwPOdxjqJqb71t2" 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) --5X4CtbiKQrrVmcBjTKHwPOdxjqJqb71t2 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: <1aa1c59d-5f40-5b99-62ec-dd9cf579300a@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> <32cb23d5-66ae-1ffc-ce5b-3c83fb80a434@redhat.com> In-Reply-To: <32cb23d5-66ae-1ffc-ce5b-3c83fb80a434@redhat.com> Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: quoted-printable On 08.06.2016 16:38, Max Reitz wrote: > 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 t= he >>> 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 = not >>> 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. >> >> Careful, this "wrong" backing file might actually be intended! >=20 > True. >=20 > 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). >=20 > So let's go through everything. >=20 > =3D=3D drive-mirror with absolute-paths =3D=3D >=20 > 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. >=20 > =3D=3D drive-mirror with existing =3D=3D >=20 > 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. >=20 > 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. >=20 > =3D=3D blockdev-mirror =3D=3D >=20 > 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. >=20 > 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 thin= k > a blockdev- command should do this kind of magic). Good news: Turns out I was wrong. I was somehow mixing things up with blockdev-snapshot (don't ask me why, I have no clue). So I think it'd be fine to rely on the user that the backing chain of the target is correct. Max > 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. >=20 >=20 > Does that sound right? >=20 > Max >=20 >=20 >> 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, an= d >> then mirror in "existing" mode. >> >> The intention is obviously that after the job completion the new backi= ng >> chain is used and not the old one. >> >> 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: >> >> Eric, can you tell us whether libvirt makes use of such a setup? >> >> 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 yo= u >> know who else would know? >> >>> Thus, instead of invoking bdrv_open_backing_file(), just set the corr= ect >>> 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 >> >> Leaving the actual code review for later when we have decided what >> semantics we even want. >> >> Kevin >> >=20 >=20 --5X4CtbiKQrrVmcBjTKHwPOdxjqJqb71t2 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 iQEcBAEBCAAGBQJXWE3DAAoJEDuxQgLoOKytzSgH/0BdYQZctJY+e/magAH3vuFa PAx48g9O7vAgfTtvFiiBTTrYHnF5BksoWs233iEUKK+kHDaZLv+zNNwz+mdJGQjz rMer0CK3Q7cZZvyi/qGKvzoA0u0bOWRIXDxw0mtnVKt+5bwA13RB8h5C5tpHtAd/ 6f/yrI057YBbjItwPtJwmijOh2LTPa6Npd3+SBYF3GHgdNns6TLLfVcirbLvZ9LT IwfjSPtXxS0FwOT8zMw5eWHmyxwfjQ6Vjh9XBqbb06Mql6Z/lRC2wUUOQr5xMigi P3QyS5m8coHRVYjH9WfBqZl/vehfLZDhM7VvE19c4u++Xnppx/tZ4mmmc5wx8oM= =V6TO -----END PGP SIGNATURE----- --5X4CtbiKQrrVmcBjTKHwPOdxjqJqb71t2--