From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LSaIQ-0000s8-QZ for qemu-devel@nongnu.org; Thu, 29 Jan 2009 12:03:19 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LSaIO-0000r9-Ak for qemu-devel@nongnu.org; Thu, 29 Jan 2009 12:03:18 -0500 Received: from [199.232.76.173] (port=59310 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LSaIN-0000r4-Kq for qemu-devel@nongnu.org; Thu, 29 Jan 2009 12:03:15 -0500 Received: from e4.ny.us.ibm.com ([32.97.182.144]:40484) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LSaIN-0005rp-05 for qemu-devel@nongnu.org; Thu, 29 Jan 2009 12:03:15 -0500 Received: from d01relay02.pok.ibm.com (d01relay02.pok.ibm.com [9.56.227.234]) by e4.ny.us.ibm.com (8.13.1/8.13.1) with ESMTP id n0TH1SvI013883 for ; Thu, 29 Jan 2009 12:01:28 -0500 Received: from d01av04.pok.ibm.com (d01av04.pok.ibm.com [9.56.224.64]) by d01relay02.pok.ibm.com (8.13.8/8.13.8/NCO v9.1) with ESMTP id n0TH3EID182232 for ; Thu, 29 Jan 2009 12:03:14 -0500 Received: from d01av04.pok.ibm.com (loopback [127.0.0.1]) by d01av04.pok.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id n0TH3DuD013260 for ; Thu, 29 Jan 2009 12:03:13 -0500 Received: from squirrel.codemonkey.ws (sig-9-65-71-35.mts.ibm.com [9.65.71.35]) by d01av04.pok.ibm.com (8.12.11.20060308/8.12.11) with ESMTP id n0TH38Ye012989 for ; Thu, 29 Jan 2009 12:03:09 -0500 Message-ID: <4981E13F.5010700@us.ibm.com> Date: Thu, 29 Jan 2009 11:02:55 -0600 From: Anthony Liguori MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH] fix raw_aio_read\write error handling References: <4981BFD0.8020006@eu.citrix.com> In-Reply-To: <4981BFD0.8020006@eu.citrix.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Stefano Stabellini wrote: > Currently when qemu_paio_read or qemu_paio_write return an error we call > qemu_aio_release without removing the request from the list. > I know that in the current implementation qemu_paio_write\read don't return > any error, but still the behavior is wrong, especially considering > that the implementation of these two functions is likely to change in is > the future. > This patch fixes the problem adding a raw_aio_remove function that > removes the callback from the queue and also calls qemu_aio_release. > raw_aio_remove is called by raw_aio_read, raw_aio_write and > raw_aio_cancel. > Good catch. Applied. Thanks. Regards, Anthony Liguori > Signed-off-by: Stefano Stabellini > > > --- > > diff --git a/block-raw-posix.c b/block-raw-posix.c > index 4404eb1..ac88fc3 100644 > --- a/block-raw-posix.c > +++ b/block-raw-posix.c > @@ -598,6 +598,24 @@ static void raw_aio_em_cb(void* opaque) > qemu_aio_release(acb); > } > > +static void raw_aio_remove(RawAIOCB *acb) > +{ > + RawAIOCB **pacb; > + > + /* remove the callback from the queue */ > + pacb = &posix_aio_state->first_aio; > + for(;;) { > + if (*pacb == NULL) { > + break; > + } else if (*pacb == acb) { > + *pacb = acb->next; > + qemu_aio_release(acb); > + break; > + } > + pacb = &acb->next; > + } > +} > + > static BlockDriverAIOCB *raw_aio_read(BlockDriverState *bs, > int64_t sector_num, uint8_t *buf, int nb_sectors, > BlockDriverCompletionFunc *cb, void *opaque) > @@ -623,7 +641,7 @@ static BlockDriverAIOCB *raw_aio_read(BlockDriverState *bs, > if (!acb) > return NULL; > if (qemu_paio_read(&acb->aiocb) < 0) { > - qemu_aio_release(acb); > + raw_aio_remove(acb); > return NULL; > } > return &acb->common; > @@ -654,7 +672,7 @@ static BlockDriverAIOCB *raw_aio_write(BlockDriverState *bs, > if (!acb) > return NULL; > if (qemu_paio_write(&acb->aiocb) < 0) { > - qemu_aio_release(acb); > + raw_aio_remove(acb); > return NULL; > } > return &acb->common; > @@ -664,7 +682,6 @@ static void raw_aio_cancel(BlockDriverAIOCB *blockacb) > { > int ret; > RawAIOCB *acb = (RawAIOCB *)blockacb; > - RawAIOCB **pacb; > > ret = qemu_paio_cancel(acb->aiocb.aio_fildes, &acb->aiocb); > if (ret == QEMU_PAIO_NOTCANCELED) { > @@ -673,18 +690,7 @@ static void raw_aio_cancel(BlockDriverAIOCB *blockacb) > while (qemu_paio_error(&acb->aiocb) == EINPROGRESS); > } > > - /* remove the callback from the queue */ > - pacb = &posix_aio_state->first_aio; > - for(;;) { > - if (*pacb == NULL) { > - break; > - } else if (*pacb == acb) { > - *pacb = acb->next; > - qemu_aio_release(acb); > - break; > - } > - pacb = &acb->next; > - } > + raw_aio_remove(acb); > } > #else /* CONFIG_AIO */ > static int posix_aio_init(void) > > > >