Received: from eggs.gnu.org ([2001:4830:134:3::10]:58588) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cCeFh-0002zi-Rw for qemu-devel@nongnu.org; Thu, 01 Dec 2016 22:11:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cCeFg-0003Zs-Om for qemu-devel@nongnu.org; Thu, 01 Dec 2016 22:11:09 -0500 References: <1477928314-11184-1-git-send-email-famz@redhat.com> From: Max Reitz Message-ID: <4625825f-00d5-6749-10fd-5529c9ae69dd@redhat.com> Date: Fri, 2 Dec 2016 04:10:59 +0100 MIME-Version: 1.0 In-Reply-To: <1477928314-11184-1-git-send-email-famz@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="h5l9jMDc90FvHbpP7L1E7e5V8wAqoXuRm" Subject: Re: [Qemu-devel] [PATCH 00/14] block: Image locking series List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Fam Zheng , qemu-devel@nongnu.org Cc: "Daniel P. Berrange" , Kevin Wolf , qemu-block@nongnu.org, rjones@redhat.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --h5l9jMDc90FvHbpP7L1E7e5V8wAqoXuRm From: Max Reitz To: Fam Zheng , qemu-devel@nongnu.org Cc: "Daniel P. Berrange" , Kevin Wolf , qemu-block@nongnu.org, rjones@redhat.com Message-ID: <4625825f-00d5-6749-10fd-5529c9ae69dd@redhat.com> Subject: Re: [PATCH 00/14] block: Image locking series References: <1477928314-11184-1-git-send-email-famz@redhat.com> In-Reply-To: <1477928314-11184-1-git-send-email-famz@redhat.com> Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: quoted-printable On 31.10.2016 16:38, Fam Zheng wrote: > This is v9 of the image locking series. I redid the whole series, adopt= ing the > "two locks" approach from Kevin and Max. >=20 > Depends on "[Qemu-devel] [PATCH] raw-posix: Rename 'raw_s' to 'rs'" in = Max's > block branch. >=20 > Fam Zheng (14): > osdep: Add qemu_lock_fd and qemu_unlock_fd > block: Define BDRV_O_SHARE_RW > qemu-io: Set "share-rw" flag together with read-only > qemu-img: Set "share-rw" flag in read-only commands > block: Set "share-rw" flag in drive-backup when sync=3Dnone > block: Set "share-rw" flag for incoming migration > iotests: 055: Don't attach the drive to vm for drive-backup > iotests: 030: Read-only open image for getting map > iotests: 087: Don't attch test image twice > iotests: 085: Avoid image locking conflict > iotests: 091: Quit QEMU before checking image > tests: Use null-co:// instead of /dev/null as the dummy image > raw-posix: Implement image locking > tests: Add test-image-lock One issue I have with the series in the current state is that it does not involve the format layer. For raw images, it's fine to be shared if BDRV_O_SHARE_RW comes from the block backend, but for qcow2 images it's not. Therefore, most drivers in the format layer should force BDRV_O_SHARE_RW to be off for the protocol layer. In fact, BDRV_O_SHARE_RW does not mean that an image has to allow sharing, but it means that the block backend (i.e. the user of the block device) is fine with sharing. Therefore, it's actually very fine to set this flag for the drive-backup target because we can easily justify not to care about concurrent writes there. However, we have to have a way to override locking, and you have four patches in your series that look like they're trying to do this: We don't really have to override locking in patches 3 and 4, it's enough to give a hint to the block layer that sharing is fine (i.e. to set BDRV_O_SHARE_RW). If something in the block layer overrides this decision, we can just let the user override it again (by setting disable-lock). Patch 5 can easily justify setting BDRV_O_SHARE_RW (as said above), but it cannot justify setting disable-lock, and there is no user to do so. If the target image is e.g. in qcow2 format, we should not just force-share the image but we should fix drive-backup. Patch 6 on the other hand is very justified in force-sharing the image. Unfortunately, it doesn't really do that. Setting BDRV_O_SHARE_RW should not do that, as I said above. It should ideally set disable-lock. But then again, patch 13 does all kinds of funny force-sharing based on whether BDRV_O_INACTIVE is set, so maybe this could be the general model: Would it work to drop patch 6 and just make raw-posix always keep the image unlocked if BDRV_O_INACTIVE is set? (The issue with setting disable-lock internally is furthermore that it's raw-posix-specific (and I think that is justified) -- you cannot just set it blindly and hope it gets to the right BDS eventually.) Max --h5l9jMDc90FvHbpP7L1E7e5V8wAqoXuRm Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- iQFGBAEBCAAwFiEEkb62CjDbPohX0Rgp9AfbAGHVz0AFAlhA5kMSHG1yZWl0ekBy ZWRoYXQuY29tAAoJEPQH2wBh1c9A4IYH/1mazmuN4X0fwR5YJpU0DHXq4+uiDhMm rO8moKjishfhQ5m32CpL3s6KTGI9JDsUrA1syRfKC5vPG2110KgS91b3sIEq0rR9 WNN6RIY8aX5Lg5rn7dOGfyPDQLj8TMA3MeQ4Fdlbjp07980hRTQ1UAKOQAb9Og1J OzZoJezaCYFyAqhE3G8T8FYR8x/Q6IVuKZ6i/PgJuJ2iwD6wmCCoeVRc6ptzsigA uwf3+kKB1fpQTjLWLOs1SAGV77WNo76XG2Km3jKh+FIOiU7qrQCXnZCk7aru5huG 5f8mUhynrCrQ8rdHgWzeZwJOIfvGq8oy5gE8SC6OEDJ8nI8G6G/SMOs= =TpRm -----END PGP SIGNATURE----- --h5l9jMDc90FvHbpP7L1E7e5V8wAqoXuRm--