From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LSaHM-000055-Hf for qemu-devel@nongnu.org; Thu, 29 Jan 2009 12:02:12 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LSaHL-0008Vm-FP for qemu-devel@nongnu.org; Thu, 29 Jan 2009 12:02:11 -0500 Received: from [199.232.76.173] (port=59287 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LSaHL-0008VY-70 for qemu-devel@nongnu.org; Thu, 29 Jan 2009 12:02:11 -0500 Received: from savannah.gnu.org ([199.232.41.3]:49415 helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LSaHK-0005jB-Ie for qemu-devel@nongnu.org; Thu, 29 Jan 2009 12:02:10 -0500 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.63) (envelope-from ) id 1LSaHJ-0006Xc-UJ for qemu-devel@nongnu.org; Thu, 29 Jan 2009 17:02:10 +0000 Received: from aliguori by cvs.savannah.gnu.org with local (Exim 4.63) (envelope-from ) id 1LSaHJ-0006XX-Ia for qemu-devel@nongnu.org; Thu, 29 Jan 2009 17:02:09 +0000 MIME-Version: 1.0 Errors-To: aliguori Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Anthony Liguori Message-Id: Date: Thu, 29 Jan 2009 17:02:09 +0000 Subject: [Qemu-devel] [6470] fix raw_aio_read\write error handling (Stefano Stabellini) 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 Revision: 6470 http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=6470 Author: aliguori Date: 2009-01-29 17:02:08 +0000 (Thu, 29 Jan 2009) Log Message: ----------- fix raw_aio_read\write error handling (Stefano Stabellini) 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. Signed-off-by: Stefano Stabellini Signed-off-by: Anthony Liguori Modified Paths: -------------- trunk/block-raw-posix.c Modified: trunk/block-raw-posix.c =================================================================== --- trunk/block-raw-posix.c 2009-01-28 21:58:29 UTC (rev 6469) +++ trunk/block-raw-posix.c 2009-01-29 17:02:08 UTC (rev 6470) @@ -598,6 +598,24 @@ 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 @@ 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 @@ 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 @@ { 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 @@ 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)