From patchwork Mon Oct 26 12:03:08 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 36903 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 7E407B7BE9 for ; Mon, 26 Oct 2009 23:08:36 +1100 (EST) Received: from localhost ([127.0.0.1]:59876 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N2ONF-0007nj-EL for incoming@patchwork.ozlabs.org; Mon, 26 Oct 2009 08:08:33 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N2OJH-0006fQ-BU for qemu-devel@nongnu.org; Mon, 26 Oct 2009 08:04:27 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N2OJB-0006cl-9r for qemu-devel@nongnu.org; Mon, 26 Oct 2009 08:04:26 -0400 Received: from [199.232.76.173] (port=39384 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N2OJA-0006cg-Uo for qemu-devel@nongnu.org; Mon, 26 Oct 2009 08:04:20 -0400 Received: from mx1.redhat.com ([209.132.183.28]:31820) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1N2OJ9-00015J-F5 for qemu-devel@nongnu.org; Mon, 26 Oct 2009 08:04:20 -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 n9QC4DZ0008523 for ; Mon, 26 Oct 2009 08:04:14 -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 n9QC4C0u009748; Mon, 26 Oct 2009 08:04:13 -0400 From: Kevin Wolf To: qemu-devel@nongnu.org Date: Mon, 26 Oct 2009 13:03:08 +0100 Message-Id: <1256558588-10107-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] Remove aio_ctx from paio_* interface 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 The context parameter in paio_submit isn't used anyway, so there is no reason why block drivers should need to remember it. This also avoids passing a Linux AIO context to paio_submit (which doesn't do any harm as long as the parameter is unused, but it is highly confusing). Signed-off-by: Kevin Wolf Reviewed-by: Christoph Hellwig --- To be applied on top of the bdrv_read/write emulation fix. block/raw-posix-aio.h | 4 ++-- block/raw-posix.c | 10 ++++------ posix-aio-compat.c | 11 +++++------ 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/block/raw-posix-aio.h b/block/raw-posix-aio.h index a2d4348..dfc63b8 100644 --- a/block/raw-posix-aio.h +++ b/block/raw-posix-aio.h @@ -26,8 +26,8 @@ /* posix-aio-compat.c - thread pool based implementation */ -void *paio_init(void); -BlockDriverAIOCB *paio_submit(BlockDriverState *bs, void *aio_ctx, int fd, +int paio_init(void); +BlockDriverAIOCB *paio_submit(BlockDriverState *bs, int fd, int64_t sector_num, QEMUIOVector *qiov, int nb_sectors, BlockDriverCompletionFunc *cb, void *opaque, int type); BlockDriverAIOCB *paio_ioctl(BlockDriverState *bs, int fd, diff --git a/block/raw-posix.c b/block/raw-posix.c index 20b37a7..f396247 100644 --- a/block/raw-posix.c +++ b/block/raw-posix.c @@ -107,7 +107,6 @@ typedef struct BDRVRawState { int type; unsigned int lseek_err_cnt; int open_flags; - void *aio_ctx; #if defined(__linux__) /* linux floppy specific */ int64_t fd_open_time; @@ -117,6 +116,7 @@ typedef struct BDRVRawState { #endif #ifdef CONFIG_LINUX_AIO int use_aio; + void *aio_ctx; #endif uint8_t* aligned_buf; } BDRVRawState; @@ -181,8 +181,7 @@ static int raw_open_common(BlockDriverState *bs, const char *filename, } else #endif { - s->aio_ctx = paio_init(); - if (!s->aio_ctx) { + if (paio_init() < 0) { goto out_free_buf; } #ifdef CONFIG_LINUX_AIO @@ -554,7 +553,7 @@ static BlockDriverAIOCB *raw_aio_submit(BlockDriverState *bs, } } - return paio_submit(bs, s->aio_ctx, s->fd, sector_num, qiov, nb_sectors, + return paio_submit(bs, s->fd, sector_num, qiov, nb_sectors, cb, opaque, type); } @@ -582,8 +581,7 @@ static BlockDriverAIOCB *raw_aio_flush(BlockDriverState *bs, if (fd_open(bs) < 0) return NULL; - return paio_submit(bs, s->aio_ctx, s->fd, 0, NULL, 0, - cb, opaque, QEMU_AIO_FLUSH); + return paio_submit(bs, s->fd, 0, NULL, 0, cb, opaque, QEMU_AIO_FLUSH); } static void raw_close(BlockDriverState *bs) diff --git a/posix-aio-compat.c b/posix-aio-compat.c index ec58288..7f391c9 100644 --- a/posix-aio-compat.c +++ b/posix-aio-compat.c @@ -556,7 +556,7 @@ static AIOPool raw_aio_pool = { .cancel = paio_cancel, }; -BlockDriverAIOCB *paio_submit(BlockDriverState *bs, void *aio_ctx, int fd, +BlockDriverAIOCB *paio_submit(BlockDriverState *bs, int fd, int64_t sector_num, QEMUIOVector *qiov, int nb_sectors, BlockDriverCompletionFunc *cb, void *opaque, int type) { @@ -607,7 +607,7 @@ BlockDriverAIOCB *paio_ioctl(BlockDriverState *bs, int fd, return &acb->common; } -void *paio_init(void) +int paio_init(void) { struct sigaction act; PosixAioState *s; @@ -615,7 +615,7 @@ void *paio_init(void) int ret; if (posix_aio_state) - return posix_aio_state; + return 0; s = qemu_malloc(sizeof(PosixAioState)); @@ -627,7 +627,7 @@ void *paio_init(void) s->first_aio = NULL; if (pipe(fds) == -1) { fprintf(stderr, "failed to create pipe\n"); - return NULL; + return -1; } s->rfd = fds[0]; @@ -650,6 +650,5 @@ void *paio_init(void) QTAILQ_INIT(&request_list); posix_aio_state = s; - - return posix_aio_state; + return 0; }