From patchwork Thu Oct 22 15:54:39 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 36701 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id C0834B7BB2 for ; Fri, 23 Oct 2009 03:10:06 +1100 (EST) Received: from localhost ([127.0.0.1]:39968 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N10El-00080v-TN for incoming@patchwork.ozlabs.org; Thu, 22 Oct 2009 12:10:03 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N101G-0001O8-Cz for qemu-devel@nongnu.org; Thu, 22 Oct 2009 11:56:06 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N1016-0001FV-NA for qemu-devel@nongnu.org; Thu, 22 Oct 2009 11:56:01 -0400 Received: from [199.232.76.173] (port=34380 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N1016-0001FA-Ba for qemu-devel@nongnu.org; Thu, 22 Oct 2009 11:55:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:64614) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1N1015-00042E-F2 for qemu-devel@nongnu.org; Thu, 22 Oct 2009 11:55:55 -0400 Received: from int-mx04.intmail.prod.int.phx2.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.17]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n9MFtssr032123 for ; Thu, 22 Oct 2009 11:55:54 -0400 Received: from localhost.localdomain (dhcp-5-175.str.redhat.com [10.32.5.175]) by int-mx04.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id n9MFtlO1003324; Thu, 22 Oct 2009 11:55:53 -0400 From: Kevin Wolf To: qemu-devel@nongnu.org Date: Thu, 22 Oct 2009 17:54:39 +0200 Message-Id: <1256226882-26434-6-git-send-email-kwolf@redhat.com> In-Reply-To: <1256226882-26434-1-git-send-email-kwolf@redhat.com> References: <1256226882-26434-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.17 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Cc: Kevin Wolf Subject: [Qemu-devel] [PATCH 5/8] block: Use new AsyncContext for bdrv_read/write emulation X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org bdrv_read/write emulation is used as the perfect example why we need something like AsyncContexts. So maybe they better start using it. Signed-off-by: Kevin Wolf --- block.c | 22 ++++++++++++++++++---- 1 files changed, 18 insertions(+), 4 deletions(-) diff --git a/block.c b/block.c index 33f3d65..fa0de25 100644 --- a/block.c +++ b/block.c @@ -1696,19 +1696,26 @@ static int bdrv_read_em(BlockDriverState *bs, int64_t sector_num, struct iovec iov; QEMUIOVector qiov; + async_context_push(); + async_ret = NOT_DONE; iov.iov_base = (void *)buf; iov.iov_len = nb_sectors * 512; qemu_iovec_init_external(&qiov, &iov, 1); acb = bdrv_aio_readv(bs, sector_num, &qiov, nb_sectors, bdrv_rw_em_cb, &async_ret); - if (acb == NULL) - return -1; + if (acb == NULL) { + async_ret = -1; + goto fail; + } while (async_ret == NOT_DONE) { qemu_aio_wait(); } + +fail: + async_context_pop(); return async_ret; } @@ -1720,17 +1727,24 @@ static int bdrv_write_em(BlockDriverState *bs, int64_t sector_num, struct iovec iov; QEMUIOVector qiov; + async_context_push(); + async_ret = NOT_DONE; iov.iov_base = (void *)buf; iov.iov_len = nb_sectors * 512; qemu_iovec_init_external(&qiov, &iov, 1); acb = bdrv_aio_writev(bs, sector_num, &qiov, nb_sectors, bdrv_rw_em_cb, &async_ret); - if (acb == NULL) - return -1; + if (acb == NULL) { + async_ret = -1; + goto fail; + } while (async_ret == NOT_DONE) { qemu_aio_wait(); } + +fail: + async_context_pop(); return async_ret; }