From patchwork Tue Mar 12 07:05:43 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: MORITA Kazutaka X-Patchwork-Id: 226825 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 4AEE42C029A for ; Tue, 12 Mar 2013 18:07:00 +1100 (EST) Received: from localhost ([::1]:56582 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UFJIY-00041X-Ch for incoming@patchwork.ozlabs.org; Tue, 12 Mar 2013 03:06:58 -0400 Received: from eggs.gnu.org ([208.118.235.92]:33603) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UFJI5-0003vf-7X for qemu-devel@nongnu.org; Tue, 12 Mar 2013 03:06:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UFJI1-0005ZQ-Ub for qemu-devel@nongnu.org; Tue, 12 Mar 2013 03:06:29 -0400 Received: from sh.osrg.net ([192.16.179.4]:59034) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UFJI1-0005YT-EY for qemu-devel@nongnu.org; Tue, 12 Mar 2013 03:06:25 -0400 Received: from fs.osrg.net (localns.osrg.net [10.0.0.11]) by sh.osrg.net (8.14.4/8.14.4/OSRG-NET) with ESMTP id r2C76KVZ001029; Tue, 12 Mar 2013 16:06:21 +0900 Received: from localhost (unknown [10.32.32.72]) by fs.osrg.net (Postfix) with ESMTP id 9A980F944; Tue, 12 Mar 2013 16:06:20 +0900 (JST) From: MORITA Kazutaka To: kwolf@redhat.com, stefanha@redhat.com Date: Tue, 12 Mar 2013 16:05:43 +0900 Message-Id: <1363071943-29248-3-git-send-email-morita.kazutaka@lab.ntt.co.jp> X-Mailer: git-send-email 1.8.1.3.566.gaa39828 In-Reply-To: <1363071943-29248-1-git-send-email-morita.kazutaka@lab.ntt.co.jp> References: <1363071943-29248-1-git-send-email-morita.kazutaka@lab.ntt.co.jp> X-Dispatcher: imput version 20100215(IM150) Lines: 55 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.3.9 (sh.osrg.net [192.16.179.4]); Tue, 12 Mar 2013 16:06:21 +0900 (JST) X-Virus-Scanned: clamav-milter 0.97.6 at sh X-Virus-Status: Clean X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 192.16.179.4 Cc: qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH v2 2/2] sheepdog: set io_flush handler in do_co_req X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org If an io_flush handler is not set, qemu_aio_wait doesn't invoke callbacks. Signed-off-by: MORITA Kazutaka --- block/sheepdog.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/block/sheepdog.c b/block/sheepdog.c index 27abef2..4245328 100644 --- a/block/sheepdog.c +++ b/block/sheepdog.c @@ -501,6 +501,13 @@ static void restart_co_req(void *opaque) qemu_coroutine_enter(co, NULL); } +static int have_co_req(void *opaque) +{ + /* this handler is set only when there is a pending request, so + * always returns 1. */ + return 1; +} + typedef struct SheepdogReqCo { int sockfd; SheepdogReq *hdr; @@ -523,14 +530,14 @@ static coroutine_fn void do_co_req(void *opaque) unsigned int *rlen = srco->rlen; co = qemu_coroutine_self(); - qemu_aio_set_fd_handler(sockfd, NULL, restart_co_req, NULL, co); + qemu_aio_set_fd_handler(sockfd, NULL, restart_co_req, have_co_req, co); ret = send_co_req(sockfd, hdr, data, wlen); if (ret < 0) { goto out; } - qemu_aio_set_fd_handler(sockfd, restart_co_req, NULL, NULL, co); + qemu_aio_set_fd_handler(sockfd, restart_co_req, NULL, have_co_req, co); ret = qemu_co_recv(sockfd, hdr, sizeof(*hdr)); if (ret < sizeof(*hdr)) { @@ -553,6 +560,8 @@ static coroutine_fn void do_co_req(void *opaque) } ret = 0; out: + /* there is at most one request for this sockfd, so it is safe to + * set each handler to NULL. */ qemu_aio_set_fd_handler(sockfd, NULL, NULL, NULL, NULL); srco->ret = ret;