From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=51919 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pan3s-0005mU-Nc for qemu-devel@nongnu.org; Thu, 06 Jan 2011 05:27:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Pan3r-0000jN-1R for qemu-devel@nongnu.org; Thu, 06 Jan 2011 05:27:16 -0500 Received: from e23smtp09.au.ibm.com ([202.81.31.142]:40564) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Pan3q-0000jE-GF for qemu-devel@nongnu.org; Thu, 06 Jan 2011 05:27:14 -0500 Received: from d23relay03.au.ibm.com (d23relay03.au.ibm.com [202.81.31.245]) by e23smtp09.au.ibm.com (8.14.4/8.13.1) with ESMTP id p06ARCL8011788 for ; Thu, 6 Jan 2011 21:27:12 +1100 Received: from d23av02.au.ibm.com (d23av02.au.ibm.com [9.190.235.138]) by d23relay03.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p06ARCqF1409252 for ; Thu, 6 Jan 2011 21:27:12 +1100 Received: from d23av02.au.ibm.com (loopback [127.0.0.1]) by d23av02.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p06ARC83009204 for ; Thu, 6 Jan 2011 21:27:12 +1100 Date: Thu, 6 Jan 2011 15:57:08 +0530 From: Arun R Bharadwaj Message-ID: <20110106102708.GB17489@linux.vnet.ibm.com> References: <20110104052627.15887.43436.stgit@localhost6.localdomain6> <20110104052708.15887.7563.stgit@localhost6.localdomain6> <20110105195343.GA9821@stefanha-thinkpad.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <20110105195343.GA9821@stefanha-thinkpad.localdomain> Subject: [Qemu-devel] Re: [PATCH 01/13] Add aiocb_mutex and aiocb_completion. Reply-To: arun@linux.vnet.ibm.com List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: aliguori@us.ibm.com, qemu-devel@nongnu.org, aneesh.kumar@linux.vnet.ibm.com * Stefan Hajnoczi [2011-01-05 19:53:44]: > On Tue, Jan 04, 2011 at 10:57:08AM +0530, Arun R Bharadwaj wrote: > > @@ -545,13 +555,19 @@ static void paio_cancel(BlockDriverAIOCB *blockacb) > > } > > mutex_unlock(&lock); > > > > - if (active) { > > - /* fail safe: if the aio could not be canceled, we wait for > > - it */ > > - while (qemu_paio_error(acb) == EINPROGRESS) > > - ; > > + qemu_mutex_lock(&aiocb_mutex); > > + if (!active) { > > + acb->ret = -ECANCELED; > > + } else { > > + while (acb->ret == -EINPROGRESS) { > > + /* > > + * fail safe: if the aio could not be canceled, > > + * we wait for it > > + */ > > + qemu_cond_wait(&aiocb_completion, &aiocb_mutex); > > + } > > } > > - > > + qemu_mutex_unlock(&aiocb_mutex); > > paio_remove(acb); > > } > > acb->ret and acb->active have been moved under aiocb_mutex. They are still > accessed under lock here and this needs to be fixed: > > mutex_lock(&lock); > if (!acb->active) { > QTAILQ_REMOVE(&request_list, acb, node); > acb->ret = -ECANCELED; > } else if (acb->ret == -EINPROGRESS) { > active = 1; > } > mutex_unlock(&lock); > You are right. This needs to go under aiocb_mutex too. -arun > Stefan