From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42769) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z3Ple-0002hf-OC for qemu-devel@nongnu.org; Fri, 12 Jun 2015 10:17:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z3Pld-0007oc-Qh for qemu-devel@nongnu.org; Fri, 12 Jun 2015 10:17:10 -0400 Message-ID: <557AE9D8.9010607@redhat.com> Date: Fri, 12 Jun 2015 16:16:56 +0200 From: Max Reitz 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: text/plain; charset=iso-8859-15; format=flowed Content-Transfer-Encoding: 7bit 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: berto@igalia.com, armbru@redhat.com, qemu-devel@nongnu.org On 10.06.2015 15:47, 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. > > The currently existing callers mostly ensure that there is no I/O > pending on nodes that are swapped. In detail, this is: > > 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. > > 2. snapshot=on in bdrv_open(). We're in the middle of opening the image > (both the original image and its temporary overlay), so there can't > be any I/O in flight yet. > > 3. Mirroring. bdrv_drain() is already used on the source device so that > the mirror doesn't miss anything. However, the main loop runs between > that and the bdrv_swap() (which is actually a bug, being addressed in > another series), so there is a small window in which new I/O might be > issued that would be in flight during bdrv_swap(). > > 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. > > Signed-off-by: Kevin Wolf > --- > block.c | 6 ++++++ > 1 file changed, 6 insertions(+) Reviewed-by: Max Reitz