From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39429) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a9NAN-0003at-Fg for qemu-devel@nongnu.org; Wed, 16 Dec 2015 20:15:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a9NAI-0007an-Fq for qemu-devel@nongnu.org; Wed, 16 Dec 2015 20:15:35 -0500 Received: from mx1.redhat.com ([209.132.183.28]:53960) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a9NAI-0007ad-9f for qemu-devel@nongnu.org; Wed, 16 Dec 2015 20:15:30 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id E9F6529B225 for ; Thu, 17 Dec 2015 01:15:29 +0000 (UTC) Date: Thu, 17 Dec 2015 09:15:27 +0800 From: Fam Zheng Message-ID: <20151217011527.GB20007@ad.usersys.redhat.com> References: <1450290827-30508-2-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1450290827-30508-2-git-send-email-pbonzini@redhat.com> Subject: Re: [Qemu-devel] [PATCH] scsi: always call notifier on async cancellation List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: qemu-devel@nongnu.org On Wed, 12/16 19:33, Paolo Bonzini wrote: > This was found by code inspection. If the request is cancelled twice, > the notifier is never called on the second cancellation request, > and hence for example a TMF might never finish. > > Signed-off-by: Paolo Bonzini > --- > hw/scsi/scsi-bus.c | 3 --- > 1 file changed, 3 deletions(-) > > diff --git a/hw/scsi/scsi-bus.c b/hw/scsi/scsi-bus.c > index 524a998..4c121fe 100644 > --- a/hw/scsi/scsi-bus.c > +++ b/hw/scsi/scsi-bus.c > @@ -1759,9 +1759,6 @@ void scsi_req_cancel_async(SCSIRequest *req, Notifier *notifier) > if (notifier) { > notifier_list_add(&req->cancel_notifiers, notifier); > } > - if (req->io_canceled) { > - return; > - } > scsi_req_ref(req); > scsi_req_dequeue(req); > req->io_canceled = true; if (req->aiocb) { blk_aio_cancel_async(req->aiocb); } else { scsi_req_cancel_complete(req); } A second TMF must be blk_aio_cancel_async case, otherwise the first one would have already completed the request synchronously in scsi_req_cancel_complete. With that in mind, I think returning early is not a problem. But I suppose these are also idempotent so this change is not breaking anything, either. Fam