Skip to content

Commit

Permalink
sheepdog: use non-blocking fd in coroutine context
Browse files Browse the repository at this point in the history
Using a blocking socket in the coroutine context reduces the chance of
switching to other work.  This patch makes the sheepdog driver use a
non-blocking fd always.

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
  • Loading branch information
kazum authored and stefanhaRH committed Mar 15, 2013
1 parent 381b487 commit 0d6db30
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions block/sheepdog.c
Expand Up @@ -468,6 +468,8 @@ static int connect_to_sdog(BDRVSheepdogState *s)
if (err != NULL) {
qerror_report_err(err);
error_free(err);
} else {
socket_set_nonblock(fd);
}

return fd;
Expand Down Expand Up @@ -523,7 +525,6 @@ static coroutine_fn void do_co_req(void *opaque)
co = qemu_coroutine_self();
qemu_aio_set_fd_handler(sockfd, NULL, restart_co_req, NULL, co);

socket_set_block(sockfd);
ret = send_co_req(sockfd, hdr, data, wlen);
if (ret < 0) {
goto out;
Expand Down Expand Up @@ -553,7 +554,6 @@ static coroutine_fn void do_co_req(void *opaque)
ret = 0;
out:
qemu_aio_set_fd_handler(sockfd, NULL, NULL, NULL, NULL);
socket_set_nonblock(sockfd);

srco->ret = ret;
srco->finished = true;
Expand Down Expand Up @@ -776,8 +776,6 @@ static int get_sheep_fd(BDRVSheepdogState *s)
return fd;
}

socket_set_nonblock(fd);

qemu_aio_set_fd_handler(fd, co_read_response, NULL, aio_flush_request, s);
return fd;
}
Expand Down

0 comments on commit 0d6db30

Please sign in to comment.