|
@@ -575,13 +575,6 @@ static coroutine_fn int send_co_req(int sockfd, SheepdogReq *hdr, void *data,
|
|
return ret;
|
|
return ret;
|
|
}
|
|
}
|
|
|
|
|
|
-static void restart_co_req(void *opaque)
|
|
|
|
-{
|
|
|
|
- Coroutine *co = opaque;
|
|
|
|
-
|
|
|
|
- qemu_coroutine_enter(co);
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
typedef struct SheepdogReqCo {
|
|
typedef struct SheepdogReqCo {
|
|
int sockfd;
|
|
int sockfd;
|
|
BlockDriverState *bs;
|
|
BlockDriverState *bs;
|
|
@@ -592,12 +585,19 @@ typedef struct SheepdogReqCo {
|
|
unsigned int *rlen;
|
|
unsigned int *rlen;
|
|
int ret;
|
|
int ret;
|
|
bool finished;
|
|
bool finished;
|
|
|
|
+ Coroutine *co;
|
|
} SheepdogReqCo;
|
|
} SheepdogReqCo;
|
|
|
|
|
|
|
|
+static void restart_co_req(void *opaque)
|
|
|
|
+{
|
|
|
|
+ SheepdogReqCo *srco = opaque;
|
|
|
|
+
|
|
|
|
+ aio_co_wake(srco->co);
|
|
|
|
+}
|
|
|
|
+
|
|
static coroutine_fn void do_co_req(void *opaque)
|
|
static coroutine_fn void do_co_req(void *opaque)
|
|
{
|
|
{
|
|
int ret;
|
|
int ret;
|
|
- Coroutine *co;
|
|
|
|
SheepdogReqCo *srco = opaque;
|
|
SheepdogReqCo *srco = opaque;
|
|
int sockfd = srco->sockfd;
|
|
int sockfd = srco->sockfd;
|
|
SheepdogReq *hdr = srco->hdr;
|
|
SheepdogReq *hdr = srco->hdr;
|
|
@@ -605,9 +605,9 @@ static coroutine_fn void do_co_req(void *opaque)
|
|
unsigned int *wlen = srco->wlen;
|
|
unsigned int *wlen = srco->wlen;
|
|
unsigned int *rlen = srco->rlen;
|
|
unsigned int *rlen = srco->rlen;
|
|
|
|
|
|
- co = qemu_coroutine_self();
|
|
|
|
|
|
+ srco->co = qemu_coroutine_self();
|
|
aio_set_fd_handler(srco->aio_context, sockfd, false,
|
|
aio_set_fd_handler(srco->aio_context, sockfd, false,
|
|
- NULL, restart_co_req, NULL, co);
|
|
|
|
|
|
+ NULL, restart_co_req, NULL, srco);
|
|
|
|
|
|
ret = send_co_req(sockfd, hdr, data, wlen);
|
|
ret = send_co_req(sockfd, hdr, data, wlen);
|
|
if (ret < 0) {
|
|
if (ret < 0) {
|
|
@@ -615,7 +615,7 @@ static coroutine_fn void do_co_req(void *opaque)
|
|
}
|
|
}
|
|
|
|
|
|
aio_set_fd_handler(srco->aio_context, sockfd, false,
|
|
aio_set_fd_handler(srco->aio_context, sockfd, false,
|
|
- restart_co_req, NULL, NULL, co);
|
|
|
|
|
|
+ restart_co_req, NULL, NULL, srco);
|
|
|
|
|
|
ret = qemu_co_recv(sockfd, hdr, sizeof(*hdr));
|
|
ret = qemu_co_recv(sockfd, hdr, sizeof(*hdr));
|
|
if (ret != sizeof(*hdr)) {
|
|
if (ret != sizeof(*hdr)) {
|
|
@@ -643,6 +643,7 @@ out:
|
|
aio_set_fd_handler(srco->aio_context, sockfd, false,
|
|
aio_set_fd_handler(srco->aio_context, sockfd, false,
|
|
NULL, NULL, NULL, NULL);
|
|
NULL, NULL, NULL, NULL);
|
|
|
|
|
|
|
|
+ srco->co = NULL;
|
|
srco->ret = ret;
|
|
srco->ret = ret;
|
|
srco->finished = true;
|
|
srco->finished = true;
|
|
if (srco->bs) {
|
|
if (srco->bs) {
|
|
@@ -866,7 +867,7 @@ static void coroutine_fn aio_read_response(void *opaque)
|
|
* We've finished all requests which belong to the AIOCB, so
|
|
* We've finished all requests which belong to the AIOCB, so
|
|
* we can switch back to sd_co_readv/writev now.
|
|
* we can switch back to sd_co_readv/writev now.
|
|
*/
|
|
*/
|
|
- qemu_coroutine_enter(acb->coroutine);
|
|
|
|
|
|
+ aio_co_wake(acb->coroutine);
|
|
}
|
|
}
|
|
|
|
|
|
return;
|
|
return;
|
|
@@ -883,14 +884,14 @@ static void co_read_response(void *opaque)
|
|
s->co_recv = qemu_coroutine_create(aio_read_response, opaque);
|
|
s->co_recv = qemu_coroutine_create(aio_read_response, opaque);
|
|
}
|
|
}
|
|
|
|
|
|
- qemu_coroutine_enter(s->co_recv);
|
|
|
|
|
|
+ aio_co_wake(s->co_recv);
|
|
}
|
|
}
|
|
|
|
|
|
static void co_write_request(void *opaque)
|
|
static void co_write_request(void *opaque)
|
|
{
|
|
{
|
|
BDRVSheepdogState *s = opaque;
|
|
BDRVSheepdogState *s = opaque;
|
|
|
|
|
|
- qemu_coroutine_enter(s->co_send);
|
|
|
|
|
|
+ aio_co_wake(s->co_send);
|
|
}
|
|
}
|
|
|
|
|
|
/*
|
|
/*
|