From patchwork Thu Oct 22 15:54:40 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 36699 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id D70DCB7BA6 for ; Fri, 23 Oct 2009 03:07:00 +1100 (EST) Received: from localhost ([127.0.0.1]:55918 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N10Bl-0006yM-M3 for incoming@patchwork.ozlabs.org; Thu, 22 Oct 2009 12:06:57 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N101C-0001LO-PL for qemu-devel@nongnu.org; Thu, 22 Oct 2009 11:56:02 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N1017-0001Fz-2r for qemu-devel@nongnu.org; Thu, 22 Oct 2009 11:56:01 -0400 Received: from [199.232.76.173] (port=34381 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N1016-0001Fl-SI for qemu-devel@nongnu.org; Thu, 22 Oct 2009 11:55:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37814) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1N1016-00042U-AK for qemu-devel@nongnu.org; Thu, 22 Oct 2009 11:55:56 -0400 Received: from int-mx04.intmail.prod.int.phx2.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.17]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n9MFtt11028416 for ; Thu, 22 Oct 2009 11:55:55 -0400 Received: from localhost.localdomain (dhcp-5-175.str.redhat.com [10.32.5.175]) by int-mx04.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id n9MFtlO2003324; Thu, 22 Oct 2009 11:55:54 -0400 From: Kevin Wolf To: qemu-devel@nongnu.org Date: Thu, 22 Oct 2009 17:54:40 +0200 Message-Id: <1256226882-26434-7-git-send-email-kwolf@redhat.com> In-Reply-To: <1256226882-26434-1-git-send-email-kwolf@redhat.com> References: <1256226882-26434-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.17 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Cc: Kevin Wolf Subject: [Qemu-devel] [PATCH 6/8] posix-aio-compat: Honour AsyncContext X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Don't call callbacks that don't belong to the active AsyncContext. Signed-off-by: Kevin Wolf --- posix-aio-compat.c | 12 ++++++++++++ 1 files changed, 12 insertions(+), 0 deletions(-) diff --git a/posix-aio-compat.c b/posix-aio-compat.c index 4901539..ec58288 100644 --- a/posix-aio-compat.c +++ b/posix-aio-compat.c @@ -48,6 +48,8 @@ struct qemu_paiocb { ssize_t ret; int active; struct qemu_paiocb *next; + + int async_context_id; }; typedef struct PosixAioState { @@ -419,6 +421,7 @@ static int posix_aio_process_queue(void *opaque) struct qemu_paiocb *acb, **pacb; int ret; int result = 0; + int async_context_id = get_async_context_id(); for(;;) { pacb = &s->first_aio; @@ -426,6 +429,13 @@ static int posix_aio_process_queue(void *opaque) acb = *pacb; if (!acb) return result; + + /* we're only interested in requests in the right context */ + if (acb->async_context_id != async_context_id) { + pacb = &acb->next; + continue; + } + ret = qemu_paio_error(acb); if (ret == ECANCELED) { /* remove the request */ @@ -558,6 +568,8 @@ BlockDriverAIOCB *paio_submit(BlockDriverState *bs, void *aio_ctx, int fd, acb->aio_type = type; acb->aio_fildes = fd; acb->ev_signo = SIGUSR2; + acb->async_context_id = get_async_context_id(); + if (qiov) { acb->aio_iov = qiov->iov; acb->aio_niov = qiov->niov;