From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:48707) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sm2wp-0005h2-6p for qemu-devel@nongnu.org; Tue, 03 Jul 2012 09:15:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Sm2wi-0007Aa-9X for qemu-devel@nongnu.org; Tue, 03 Jul 2012 09:15:18 -0400 Received: from mx1.redhat.com ([209.132.183.28]:5318) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sm2wi-0007A8-19 for qemu-devel@nongnu.org; Tue, 03 Jul 2012 09:15:12 -0400 Message-ID: <4FF2F057.7030802@redhat.com> Date: Tue, 03 Jul 2012 15:15:03 +0200 From: Kevin Wolf MIME-Version: 1.0 References: <1340749583-5292-1-git-send-email-morita.kazutaka@lab.ntt.co.jp> <1340749583-5292-4-git-send-email-morita.kazutaka@lab.ntt.co.jp> In-Reply-To: <1340749583-5292-4-git-send-email-morita.kazutaka@lab.ntt.co.jp> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 3/6] sheepdog: use coroutine based socket functions in coroutine context List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: MORITA Kazutaka Cc: qemu-devel@nongnu.org Am 27.06.2012 00:26, schrieb MORITA Kazutaka: > This removes blocking network I/Os in coroutine context. > > Signed-off-by: MORITA Kazutaka > --- > 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) { How about replacing the non-coroutine implementation by code that creates a new coroutine and executes do_co_req() as well? This would reduce some code duplication. Kevin