From patchwork Wed Jul 27 18:25:26 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frediano Ziglio X-Patchwork-Id: 107138 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 16CD2B6F64 for ; Thu, 28 Jul 2011 04:25:39 +1000 (EST) Received: from localhost ([::1]:54823 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qm8nS-00039Q-To for incoming@patchwork.ozlabs.org; Wed, 27 Jul 2011 14:25:30 -0400 Received: from eggs.gnu.org ([140.186.70.92]:44806) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qm8nG-0002uO-Ep for qemu-devel@nongnu.org; Wed, 27 Jul 2011 14:25:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Qm8nE-0006j7-NV for qemu-devel@nongnu.org; Wed, 27 Jul 2011 14:25:18 -0400 Received: from mail-wy0-f173.google.com ([74.125.82.173]:41250) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qm8nE-0006hL-Ef for qemu-devel@nongnu.org; Wed, 27 Jul 2011 14:25:16 -0400 Received: by mail-wy0-f173.google.com with SMTP id 28so1354128wyf.4 for ; Wed, 27 Jul 2011 11:25:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=CDjsXBcB4SPEbAhjc7W4TWACGFhCdKJ65Rdr+270uMs=; b=BZ0rZz4gu4KsJek+ZxOkX88uQiHLTje0LN6QgC92/SqHblla+7rvL3hHmyufwWxRCg Wvw2IwxF3XWKQ/5xeBEp8/Vd6AyFK6gnkO0q4QEs/f6QfpFsySIKAyufsH0nN8mh5KHc /Ln9I9CT8w53+HskipiELwZ5RlnEz6Psmt0nY= Received: by 10.216.82.146 with SMTP id o18mr138185wee.7.1311791115922; Wed, 27 Jul 2011 11:25:15 -0700 (PDT) Received: from obol602.localdomain (net-2-37-106-50.cust.dsl.vodafone.it [2.37.106.50]) by mx.google.com with ESMTPS id w45sm110498wec.0.2011.07.27.11.25.14 (version=SSLv3 cipher=OTHER); Wed, 27 Jul 2011 11:25:15 -0700 (PDT) From: Frediano Ziglio To: Kevin Wolf Date: Wed, 27 Jul 2011 20:25:26 +0200 Message-Id: <1311791126-11383-3-git-send-email-freddy77@gmail.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1311791126-11383-1-git-send-email-freddy77@gmail.com> References: <1311791126-11383-1-git-send-email-freddy77@gmail.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 74.125.82.173 Cc: qemu-devel@nongnu.org, Frediano Ziglio Subject: [Qemu-devel] [PATCH 2/2] aio: use Linux AIO even if nocache is not specified 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 Currently Linux AIO are used only if nocache is specified. Linux AIO works in all cases. The only problem is that currently Linux AIO does not align data so I add a test that use POSIX AIO in this case. Signed-off-by: Frediano Ziglio --- block/raw-posix.c | 23 ++++++++++------------- 1 files changed, 10 insertions(+), 13 deletions(-) diff --git a/block/raw-posix.c b/block/raw-posix.c index 27ae81e..078a256 100644 --- a/block/raw-posix.c +++ b/block/raw-posix.c @@ -236,21 +236,16 @@ static int raw_open_common(BlockDriverState *bs, const char *filename, } #ifdef CONFIG_LINUX_AIO - if ((bdrv_flags & (BDRV_O_NOCACHE|BDRV_O_NATIVE_AIO)) == - (BDRV_O_NOCACHE|BDRV_O_NATIVE_AIO)) { + s->use_aio = 0; + if ((bdrv_flags & BDRV_O_NATIVE_AIO)) { s->aio_ctx = laio_init(); if (!s->aio_ctx) { goto out_free_buf; } s->use_aio = 1; - } else -#endif - { -#ifdef CONFIG_LINUX_AIO - s->use_aio = 0; -#endif } +#endif #ifdef CONFIG_XFS if (platform_test_xfs_fd(s->fd)) { @@ -592,14 +587,16 @@ static BlockDriverAIOCB *raw_aio_submit(BlockDriverState *bs, if (s->aligned_buf) { if (!qiov_is_aligned(bs, qiov)) { type |= QEMU_AIO_MISALIGNED; -#ifdef CONFIG_LINUX_AIO - } else if (s->use_aio) { - return laio_submit(bs, s->aio_ctx, s->fd, sector_num, qiov, - nb_sectors, cb, opaque, type); -#endif } } +#ifdef CONFIG_LINUX_AIO + if (s->use_aio && !(type & QEMU_AIO_MISALIGNED)) { + return laio_submit(bs, s->aio_ctx, s->fd, sector_num, qiov, + nb_sectors, cb, opaque, type); + } +#endif + return paio_submit(bs, s->fd, sector_num, qiov, nb_sectors, cb, opaque, type); }