qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Frediano Ziglio <freddy77@gmail.com>
To: Kevin Wolf <kwolf@redhat.com>
Cc: qemu-devel@nongnu.org, Frediano Ziglio <freddy77@gmail.com>
Subject: [Qemu-devel] [PATCH 2/2] aio: use Linux AIO even if nocache is not specified
Date: Wed, 27 Jul 2011 20:25:26 +0200	[thread overview]
Message-ID: <1311791126-11383-3-git-send-email-freddy77@gmail.com> (raw)
In-Reply-To: <1311791126-11383-1-git-send-email-freddy77@gmail.com>

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 <freddy77@gmail.com>
---
 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);
 }
-- 
1.7.1

  parent reply	other threads:[~2011-07-27 18:25 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-27 18:25 [Qemu-devel] [PATCH 0/2] improve Linux AIO support Frediano Ziglio
2011-07-27 18:25 ` [Qemu-devel] [PATCH 1/2] linux aio: support flush operation Frediano Ziglio
2011-07-27 18:31   ` Christoph Hellwig
2011-07-27 19:52     ` Frediano Ziglio
2011-07-27 19:57       ` Christoph Hellwig
2011-07-28  7:47         ` Kevin Wolf
2011-07-28 12:15           ` Christoph Hellwig
2011-07-28 12:41             ` Kevin Wolf
2011-07-29 14:24               ` Christoph Hellwig
2011-07-29 15:33             ` Stefan Hajnoczi
2011-07-27 18:25 ` Frediano Ziglio [this message]
2011-07-27 18:32   ` [Qemu-devel] [PATCH 2/2] aio: use Linux AIO even if nocache is not specified Christoph Hellwig

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1311791126-11383-3-git-send-email-freddy77@gmail.com \
    --to=freddy77@gmail.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).