From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=39885 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PaZQj-00081h-O3 for qemu-devel@nongnu.org; Wed, 05 Jan 2011 14:53:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PaZQi-0008H5-FI for qemu-devel@nongnu.org; Wed, 05 Jan 2011 14:53:57 -0500 Received: from mtagate4.uk.ibm.com ([194.196.100.164]:49473) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PaZQi-0008Gn-8K for qemu-devel@nongnu.org; Wed, 05 Jan 2011 14:53:56 -0500 Received: from d06nrmr1307.portsmouth.uk.ibm.com (d06nrmr1307.portsmouth.uk.ibm.com [9.149.38.129]) by mtagate4.uk.ibm.com (8.13.1/8.13.1) with ESMTP id p05JrrsP025335 for ; Wed, 5 Jan 2011 19:53:53 GMT Received: from d06av03.portsmouth.uk.ibm.com (d06av03.portsmouth.uk.ibm.com [9.149.37.213]) by d06nrmr1307.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p05Jrto63702954 for ; Wed, 5 Jan 2011 19:53:55 GMT Received: from d06av03.portsmouth.uk.ibm.com (localhost.localdomain [127.0.0.1]) by d06av03.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p05JrrLs002973 for ; Wed, 5 Jan 2011 12:53:53 -0700 Date: Wed, 5 Jan 2011 19:53:44 +0000 From: Stefan Hajnoczi Message-ID: <20110105195343.GA9821@stefanha-thinkpad.localdomain> References: <20110104052627.15887.43436.stgit@localhost6.localdomain6> <20110104052708.15887.7563.stgit@localhost6.localdomain6> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20110104052708.15887.7563.stgit@localhost6.localdomain6> Subject: [Qemu-devel] Re: [PATCH 01/13] Add aiocb_mutex and aiocb_completion. List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Arun R Bharadwaj Cc: aliguori@us.ibm.com, qemu-devel@nongnu.org, aneesh.kumar@linux.vnet.ibm.com 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); Stefan