From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48251) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z2pFa-0007Mm-7F for qemu-devel@nongnu.org; Wed, 10 Jun 2015 19:17:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z2pFZ-0000ok-CF for qemu-devel@nongnu.org; Wed, 10 Jun 2015 19:17:38 -0400 Message-ID: <5578C584.40403@redhat.com> Date: Wed, 10 Jun 2015 17:17:24 -0600 From: Eric Blake MIME-Version: 1.0 References: <1433944027-28533-1-git-send-email-kwolf@redhat.com> <1433944027-28533-10-git-send-email-kwolf@redhat.com> In-Reply-To: <1433944027-28533-10-git-send-email-kwolf@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="QhVvafOt5G4aPfVKSQDfpmuXJ9SpWHQ9l" Subject: Re: [Qemu-devel] [PATCH v2 09/13] block: Drain requests before swapping nodes in bdrv_swap() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf , qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, berto@igalia.com, armbru@redhat.com, mreitz@redhat.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --QhVvafOt5G4aPfVKSQDfpmuXJ9SpWHQ9l Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 06/10/2015 07:47 AM, Kevin Wolf wrote: > bdrv_swap() requires that there are no requests in flight on either of > the two devices. The request coroutine would work on the wrong > BlockDriverState object (with bs->opaque even being interpreted as a > different type potentially) and all sorts of bad things would result > from this. >=20 > The currently existing callers mostly ensure that there is no I/O > pending on nodes that are swapped. In detail, this is: >=20 > 1. Live snapshots. This goes through qmp_transaction(), which calls > bdrv_drain_all() before doing anything. The command is executed > synchronously, so no new I/O can be issued concurrently. >=20 > 2. snapshot=3Don in bdrv_open(). We're in the middle of opening the ima= ge > (both the original image and its temporary overlay), so there can't > be any I/O in flight yet. >=20 > 3. Mirroring. bdrv_drain() is already used on the source device so that= > the mirror doesn't miss anything. However, the main loop runs betwee= n > that and the bdrv_swap() (which is actually a bug, being addressed i= n > another series), so there is a small window in which new I/O might b= e > issued that would be in flight during bdrv_swap(). >=20 > It is safer to just drain the request queue of both devices in > bdrv_swap() instead of relying on callers to do the right thing. >=20 > Signed-off-by: Kevin Wolf > --- > block.c | 6 ++++++ > 1 file changed, 6 insertions(+) >=20 Reviewed-by: Eric Blake --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --QhVvafOt5G4aPfVKSQDfpmuXJ9SpWHQ9l 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 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJVeMWEAAoJEKeha0olJ0Nq3asH/3DyA9+E8+lDDh3xeKUFSAWb SOYTUtmAxdIwSxa3mO0H9vw8IpxnEcKeYA56Kz3ljKy4aO9RcbE0+tc6i2TasVLC gGAMwbS7h9eaooNysz/HjBi7xGj4fP8C1wGGGZtp8LTMjrvVSH3o4S6IRwHOf8Yt tEtlGE+VUEbYaYmE+2MO8yZKeLplWcTNpisAb3qLeddxQDJBTqK4fX5Rr+ft603I QsSxIvWeuX7j0EQtL6UxbM5Ocn8nEvwtL3aQkegTrfXRhSMYS174wSwrkhYg8nl+ fKwDVmwixauSCWul8cYqKZvOjOqJs1AGXtqqJvhZ0cq9f8S2y1GuWRqv2r3rSHw= =savR -----END PGP SIGNATURE----- --QhVvafOt5G4aPfVKSQDfpmuXJ9SpWHQ9l--