Received: from eggs.gnu.org ([2001:4830:134:3::10]:45992) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XY3XE-0005xQ-QJ for qemu-devel@nongnu.org; Sat, 27 Sep 2014 21:44:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XY3X8-0000jt-LO for qemu-devel@nongnu.org; Sat, 27 Sep 2014 21:44:24 -0400 Received: from mx1.redhat.com ([209.132.183.28]:19676) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XY3X8-0000jg-DX for qemu-devel@nongnu.org; Sat, 27 Sep 2014 21:44:18 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s8S1iC0d016538 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Sat, 27 Sep 2014 21:44:12 -0400 Date: Sun, 28 Sep 2014 09:44:12 +0800 From: Fam Zheng Message-ID: <20140928014412.GA2467@fam-t430.nay.redhat.com> References: <1411611649-11171-1-git-send-email-famz@redhat.com> <1411611649-11171-7-git-send-email-famz@redhat.com> <5423D796.3090708@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5423D796.3090708@redhat.com> Subject: Re: [Qemu-devel] [PATCH v3 6/7] scsi: Introduce scsi_req_cancel_async List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: Kevin Wolf , qemu-devel@nongnu.org, Stefan Hajnoczi On Thu, 09/25 10:51, Paolo Bonzini wrote: > Il 25/09/2014 04:20, Fam Zheng ha scritto: > > Devices will call this function to start an asynchronous cancellation. The > > bus->info->cancel will be called after the request is canceled. > > > > Devices will probably need to track a separate TMF request that triggers this > > cancellation, and wait until the cancellation is done before completing it. So > > we store a notifier list in SCSIRequest and in scsi_req_cancel_complete we > > notify them. > > > > Signed-off-by: Fam Zheng > > --- > > hw/scsi/scsi-bus.c | 23 +++++++++++++++++++++++ > > include/hw/scsi/scsi.h | 3 +++ > > 2 files changed, 26 insertions(+) > > > > diff --git a/hw/scsi/scsi-bus.c b/hw/scsi/scsi-bus.c > > index c91db63..df7585a 100644 > > --- a/hw/scsi/scsi-bus.c > > +++ b/hw/scsi/scsi-bus.c > > @@ -566,6 +566,7 @@ SCSIRequest *scsi_req_alloc(const SCSIReqOps *reqops, SCSIDevice *d, > > req->ops = reqops; > > object_ref(OBJECT(d)); > > object_ref(OBJECT(qbus->parent)); > > + notifier_list_init(&req->cancel_notifiers); > > trace_scsi_req_alloc(req->dev->id, req->lun, req->tag); > > return req; > > } > > @@ -1725,9 +1726,31 @@ void scsi_req_cancel_complete(SCSIRequest *req) > > if (req->bus->info->cancel) { > > req->bus->info->cancel(req); > > } > > + notifier_list_notify(&req->cancel_notifiers, req); > > I think you also have to call notifier_list_notify from > scsi_req_complete, because a cancelled request might end up being > completed instead of cancelled. Yes, will update the series. > > In fact, the next obvious step (enabled by your bdrv_aio_cancel cleanup) > would be to _not_ call scsi_req_cancel_complete if we can report > completion or if there was an I/O error. This can happen for > scsi-generic, scsi_dma_complete_noio, etc. Basically, moving the > io_canceled check from the beginning of the completion routine to just > before bdrv_aio_* or dma_aio_* are called. Okay. Thanks, Fam