From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36418) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W34v5-0003Na-Nb for qemu-devel@nongnu.org; Tue, 14 Jan 2014 09:24:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W34uw-0000le-Nc for qemu-devel@nongnu.org; Tue, 14 Jan 2014 09:24:43 -0500 Received: from e7.ny.us.ibm.com ([32.97.182.137]:54689) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W34uw-0000lS-ID for qemu-devel@nongnu.org; Tue, 14 Jan 2014 09:24:34 -0500 Received: from /spool/local by e7.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 14 Jan 2014 09:24:33 -0500 Received: from b01cxnp22036.gho.pok.ibm.com (b01cxnp22036.gho.pok.ibm.com [9.57.198.26]) by d01dlp03.pok.ibm.com (Postfix) with ESMTP id 45407C9005A for ; Tue, 14 Jan 2014 09:24:28 -0500 (EST) Received: from d01av04.pok.ibm.com (d01av04.pok.ibm.com [9.56.224.64]) by b01cxnp22036.gho.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id s0EEOUAm9503208 for ; Tue, 14 Jan 2014 14:24:30 GMT Received: from d01av04.pok.ibm.com (localhost [127.0.0.1]) by d01av04.pok.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id s0EEOUdo002625 for ; Tue, 14 Jan 2014 09:24:30 -0500 From: Eric Farman Date: Tue, 14 Jan 2014 09:24:27 -0500 Message-Id: <1389709469-15111-2-git-send-email-farman@linux.vnet.ibm.com> In-Reply-To: <1389709469-15111-1-git-send-email-farman@linux.vnet.ibm.com> References: <1389709469-15111-1-git-send-email-farman@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH 1/3] scsi/virtio-scsi: Properly flush I/Os inflight during an unplug List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Paolo Bonzini When an unplug is triggered via QMP, the routine scsi_req_cancel is called to cancel any outstanding requests. However, the I/Os themselves were instantiated via an asynchronous call that will drive scsi_*_complete routines after the unplug call stack finishes. As all references to the request have been released by the cancel thread, the scsi_*_complete routines experience a range of failures when it attempts to manipulate the released storage. Before we exit back to scsi_req_cancel, we need to inform the asynchronous tasks that they were canceled. This will handle all the cleanup work performed by scsi_*_complete before we release all the references to the affected request(s). Signed-off-by: Eric Farman --- hw/scsi/virtio-scsi.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c index 6dcdd1b..a8fde04 100644 --- a/hw/scsi/virtio-scsi.c +++ b/hw/scsi/virtio-scsi.c @@ -339,6 +339,7 @@ static void virtio_scsi_request_cancelled(SCSIRequest *r) req->resp.cmd->response = VIRTIO_SCSI_S_ABORTED; } virtio_scsi_complete_req(req); + bdrv_drain_all(); } static void virtio_scsi_fail_cmd_req(VirtIOSCSIReq *req) -- 1.7.9.5