posix-aio-compat: Split out posix_aio_process_queue
We need to process the request queue and run callbacks separately from reading out the queue in a later patch, so split it out. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
parent
18f3a5151c
commit
59c7b155aa
|
@ -413,36 +413,25 @@ static int qemu_paio_error(struct qemu_paiocb *aiocb)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void posix_aio_read(void *opaque)
|
static int posix_aio_process_queue(void *opaque)
|
||||||
{
|
{
|
||||||
PosixAioState *s = opaque;
|
PosixAioState *s = opaque;
|
||||||
struct qemu_paiocb *acb, **pacb;
|
struct qemu_paiocb *acb, **pacb;
|
||||||
int ret;
|
int ret;
|
||||||
ssize_t len;
|
int result = 0;
|
||||||
|
|
||||||
/* read all bytes from signal pipe */
|
|
||||||
for (;;) {
|
|
||||||
char bytes[16];
|
|
||||||
|
|
||||||
len = read(s->rfd, bytes, sizeof(bytes));
|
|
||||||
if (len == -1 && errno == EINTR)
|
|
||||||
continue; /* try again */
|
|
||||||
if (len == sizeof(bytes))
|
|
||||||
continue; /* more to read */
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
for(;;) {
|
for(;;) {
|
||||||
pacb = &s->first_aio;
|
pacb = &s->first_aio;
|
||||||
for(;;) {
|
for(;;) {
|
||||||
acb = *pacb;
|
acb = *pacb;
|
||||||
if (!acb)
|
if (!acb)
|
||||||
goto the_end;
|
return result;
|
||||||
ret = qemu_paio_error(acb);
|
ret = qemu_paio_error(acb);
|
||||||
if (ret == ECANCELED) {
|
if (ret == ECANCELED) {
|
||||||
/* remove the request */
|
/* remove the request */
|
||||||
*pacb = acb->next;
|
*pacb = acb->next;
|
||||||
qemu_aio_release(acb);
|
qemu_aio_release(acb);
|
||||||
|
result = 1;
|
||||||
} else if (ret != EINPROGRESS) {
|
} else if (ret != EINPROGRESS) {
|
||||||
/* end of aio */
|
/* end of aio */
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
|
@ -459,13 +448,35 @@ static void posix_aio_read(void *opaque)
|
||||||
/* call the callback */
|
/* call the callback */
|
||||||
acb->common.cb(acb->common.opaque, ret);
|
acb->common.cb(acb->common.opaque, ret);
|
||||||
qemu_aio_release(acb);
|
qemu_aio_release(acb);
|
||||||
|
result = 1;
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
pacb = &acb->next;
|
pacb = &acb->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
the_end: ;
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void posix_aio_read(void *opaque)
|
||||||
|
{
|
||||||
|
PosixAioState *s = opaque;
|
||||||
|
ssize_t len;
|
||||||
|
|
||||||
|
/* read all bytes from signal pipe */
|
||||||
|
for (;;) {
|
||||||
|
char bytes[16];
|
||||||
|
|
||||||
|
len = read(s->rfd, bytes, sizeof(bytes));
|
||||||
|
if (len == -1 && errno == EINTR)
|
||||||
|
continue; /* try again */
|
||||||
|
if (len == sizeof(bytes))
|
||||||
|
continue; /* more to read */
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
posix_aio_process_queue(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int posix_aio_flush(void *opaque)
|
static int posix_aio_flush(void *opaque)
|
||||||
|
|
Loading…
Reference in New Issue