Remove aio_ctx from paio_* interface

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 <kwolf@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
Kevin Wolf 2009-10-26 13:03:08 +01:00 committed by Anthony Liguori
parent fa39472763
commit 1e5b9d2fcc
3 changed files with 11 additions and 14 deletions

View File

@ -26,8 +26,8 @@
/* posix-aio-compat.c - thread pool based implementation */ /* posix-aio-compat.c - thread pool based implementation */
void *paio_init(void); int paio_init(void);
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, int64_t sector_num, QEMUIOVector *qiov, int nb_sectors,
BlockDriverCompletionFunc *cb, void *opaque, int type); BlockDriverCompletionFunc *cb, void *opaque, int type);
BlockDriverAIOCB *paio_ioctl(BlockDriverState *bs, int fd, BlockDriverAIOCB *paio_ioctl(BlockDriverState *bs, int fd,

View File

@ -107,7 +107,6 @@ typedef struct BDRVRawState {
int type; int type;
unsigned int lseek_err_cnt; unsigned int lseek_err_cnt;
int open_flags; int open_flags;
void *aio_ctx;
#if defined(__linux__) #if defined(__linux__)
/* linux floppy specific */ /* linux floppy specific */
int64_t fd_open_time; int64_t fd_open_time;
@ -117,6 +116,7 @@ typedef struct BDRVRawState {
#endif #endif
#ifdef CONFIG_LINUX_AIO #ifdef CONFIG_LINUX_AIO
int use_aio; int use_aio;
void *aio_ctx;
#endif #endif
uint8_t* aligned_buf; uint8_t* aligned_buf;
} BDRVRawState; } BDRVRawState;
@ -185,8 +185,7 @@ static int raw_open_common(BlockDriverState *bs, const char *filename,
} else } else
#endif #endif
{ {
s->aio_ctx = paio_init(); if (paio_init() < 0) {
if (!s->aio_ctx) {
goto out_free_buf; goto out_free_buf;
} }
#ifdef CONFIG_LINUX_AIO #ifdef CONFIG_LINUX_AIO
@ -558,7 +557,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); cb, opaque, type);
} }
@ -586,8 +585,7 @@ static BlockDriverAIOCB *raw_aio_flush(BlockDriverState *bs,
if (fd_open(bs) < 0) if (fd_open(bs) < 0)
return NULL; return NULL;
return paio_submit(bs, s->aio_ctx, s->fd, 0, NULL, 0, return paio_submit(bs, s->fd, 0, NULL, 0, cb, opaque, QEMU_AIO_FLUSH);
cb, opaque, QEMU_AIO_FLUSH);
} }
static void raw_close(BlockDriverState *bs) static void raw_close(BlockDriverState *bs)

View File

@ -556,7 +556,7 @@ static AIOPool raw_aio_pool = {
.cancel = paio_cancel, .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, int64_t sector_num, QEMUIOVector *qiov, int nb_sectors,
BlockDriverCompletionFunc *cb, void *opaque, int type) BlockDriverCompletionFunc *cb, void *opaque, int type)
{ {
@ -607,7 +607,7 @@ BlockDriverAIOCB *paio_ioctl(BlockDriverState *bs, int fd,
return &acb->common; return &acb->common;
} }
void *paio_init(void) int paio_init(void)
{ {
struct sigaction act; struct sigaction act;
PosixAioState *s; PosixAioState *s;
@ -615,7 +615,7 @@ void *paio_init(void)
int ret; int ret;
if (posix_aio_state) if (posix_aio_state)
return posix_aio_state; return 0;
s = qemu_malloc(sizeof(PosixAioState)); s = qemu_malloc(sizeof(PosixAioState));
@ -627,7 +627,7 @@ void *paio_init(void)
s->first_aio = NULL; s->first_aio = NULL;
if (pipe(fds) == -1) { if (pipe(fds) == -1) {
fprintf(stderr, "failed to create pipe\n"); fprintf(stderr, "failed to create pipe\n");
return NULL; return -1;
} }
s->rfd = fds[0]; s->rfd = fds[0];
@ -650,6 +650,5 @@ void *paio_init(void)
QTAILQ_INIT(&request_list); QTAILQ_INIT(&request_list);
posix_aio_state = s; posix_aio_state = s;
return 0;
return posix_aio_state;
} }