[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 06/25] sheepdog: use coroutine based socket function
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PATCH 06/25] sheepdog: use coroutine based socket functions in coroutine context |
Date: |
Mon, 9 Jul 2012 16:16:09 +0200 |
From: MORITA Kazutaka <address@hidden>
This removes blocking network I/Os in coroutine context.
Signed-off-by: MORITA Kazutaka <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
block/sheepdog.c | 10 ++++++++--
1 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/block/sheepdog.c b/block/sheepdog.c
index 0b49c6d..5dc1d7a 100644
--- a/block/sheepdog.c
+++ b/block/sheepdog.c
@@ -541,11 +541,18 @@ static coroutine_fn int send_co_req(int sockfd,
SheepdogReq *hdr, void *data,
return ret;
}
+static coroutine_fn int do_co_req(int sockfd, SheepdogReq *hdr, void *data,
+ unsigned int *wlen, unsigned int *rlen);
+
static int do_req(int sockfd, SheepdogReq *hdr, void *data,
unsigned int *wlen, unsigned int *rlen)
{
int ret;
+ if (qemu_in_coroutine()) {
+ return do_co_req(sockfd, hdr, data, wlen, rlen);
+ }
+
socket_set_block(sockfd);
ret = send_req(sockfd, hdr, data, wlen);
if (ret < 0) {
@@ -1642,7 +1649,6 @@ static coroutine_fn int sd_co_writev(BlockDriverState
*bs, int64_t sector_num,
int ret;
if (bs->growable && sector_num + nb_sectors > bs->total_sectors) {
- /* TODO: shouldn't block here */
ret = sd_truncate(bs, (sector_num + nb_sectors) * SECTOR_SIZE);
if (ret < 0) {
return ret;
@@ -1710,7 +1716,7 @@ static int coroutine_fn
sd_co_flush_to_disk(BlockDriverState *bs)
hdr.opcode = SD_OP_FLUSH_VDI;
hdr.oid = vid_to_vdi_oid(inode->vdi_id);
- ret = do_co_req(s->flush_fd, (SheepdogReq *)&hdr, NULL, &wlen, &rlen);
+ ret = do_req(s->flush_fd, (SheepdogReq *)&hdr, NULL, &wlen, &rlen);
if (ret) {
error_report("failed to send a request to the sheep");
return ret;
--
1.7.6.5
- [Qemu-devel] [PULL 00/25] Block patches, Kevin Wolf, 2012/07/09
- [Qemu-devel] [PATCH 04/25] sheepdog: fix dprintf format strings, Kevin Wolf, 2012/07/09
- [Qemu-devel] [PATCH 05/25] sheepdog: restart I/O when socket becomes ready in do_co_req(), Kevin Wolf, 2012/07/09
- [Qemu-devel] [PATCH 03/25] blockdev: warn when copy_on_read=on and readonly=on, Kevin Wolf, 2012/07/09
- [Qemu-devel] [PATCH 01/25] qcow2: fix #ifdef'd qcow2_check_refcounts() callers, Kevin Wolf, 2012/07/09
- [Qemu-devel] [PATCH 07/25] sheepdog: make sure we don't free aiocb before sending all requests, Kevin Wolf, 2012/07/09
- [Qemu-devel] [PATCH 12/25] blkdebug: pass getlength to underlying file, Kevin Wolf, 2012/07/09
- [Qemu-devel] [PATCH 02/25] qcow2: preserve free_byte_offset when qcow2_alloc_bytes() fails, Kevin Wolf, 2012/07/09
- [Qemu-devel] [PATCH 06/25] sheepdog: use coroutine based socket functions in coroutine context,
Kevin Wolf <=
- [Qemu-devel] [PATCH 08/25] sheepdog: split outstanding list into inflight and pending, Kevin Wolf, 2012/07/09
- [Qemu-devel] [PATCH 09/25] sheepdog: traverse pending_list from the first for each time, Kevin Wolf, 2012/07/09
- [Qemu-devel] [PATCH 14/25] blkdebug: optionally tie errors to a specific sector, Kevin Wolf, 2012/07/09
- [Qemu-devel] [PATCH 10/25] blkdebug: remove sync i/o events, Kevin Wolf, 2012/07/09
- [Qemu-devel] [PATCH 16/25] block: copy over job and dirty bitmap fields in bdrv_append, Kevin Wolf, 2012/07/09
- [Qemu-devel] [PATCH 11/25] blkdebug: tiny cleanup, Kevin Wolf, 2012/07/09
- [Qemu-devel] [PATCH 17/25] block: introduce bdrv_swap, implement bdrv_append on top of it, Kevin Wolf, 2012/07/09
- [Qemu-devel] [PATCH 18/25] fdc: rewrite seek and DSKCHG bit handling, Kevin Wolf, 2012/07/09
- [Qemu-devel] [PATCH 20/25] fdc_test: update media_change test, Kevin Wolf, 2012/07/09
- [Qemu-devel] [PATCH 13/25] blkdebug: store list of active rules, Kevin Wolf, 2012/07/09