Skip to contentSkip to conversation

[5297] Refactor AIO to allow multiple AIO implementations

Qemu-devel Anthony Liguori 1 participant 2 messages Sep 22, 2008 Kbuild

lore
Share & tools
lore
#0 lore raw

Revision: 5297

          http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=5297
Author:   aliguori
Date:     2008-09-22 19:17:18 +0000 (Mon, 22 Sep 2008)

Log Message:
-----------
Refactor AIO to allow multiple AIO implementations

This patch refactors the AIO layer to allow multiple AIO implementations. It's only possible because of the recent signalfd() patch.

Right now, the AIO infrastructure is pretty specific to the block raw backend. For other block devices to implement AIO, the qemu_aio_wait function must support registration. This patch introduces a new function, qemu_aio_set_fd_handler, which can be used to register a file descriptor to be called back. qemu_aio_wait() now polls a set of file descriptors registered with this function until one becomes readable or writable.

This patch should allow the implementation of alternative AIO backends (via a thread pool or linux-aio) and AIO backends in non-traditional block devices (like NBD).

Modified Paths:
--------------

    trunk/Makefile
    trunk/Makefile.target
    trunk/block-raw-posix.c
    trunk/block-raw-win32.c
    trunk/block.c
    trunk/block.h

Added Paths:
-----------
trunk/aio.c
trunk/qemu-aio.h

Modified: trunk/Makefile
===================================================================

Makefile +1 -1
@@ -51,7 +51,7 @@
 BLOCK_OBJS+=block-cow.o block-qcow.o aes.o block-vmdk.o block-cloop.o
 BLOCK_OBJS+=block-dmg.o block-bochs.o block-vpc.o block-vvfat.o
 BLOCK_OBJS+=block-qcow2.o block-parallels.o block-nbd.o
-BLOCK_OBJS+=nbd.o block.o
+BLOCK_OBJS+=nbd.o block.o aio.o
 
 ifdef CONFIG_WIN32
 BLOCK_OBJS += block-raw-win32.o

Modified: trunk/Makefile.target
===================================================================

Makefile.target +1 -1
@@ -474,7 +474,7 @@
 ifndef CONFIG_USER_ONLY
 
 OBJS=vl.o osdep.o monitor.o pci.o loader.o isa_mmio.o machine.o net-checksum.o
-OBJS+=fw_cfg.o
+OBJS+=fw_cfg.o aio.o
 ifdef CONFIG_WIN32
 OBJS+=block-raw-win32.o
 else

Added: trunk/aio.c
===================================================================

aio.c +192 -0

192 lines not on this page · raw message

Modified: trunk/block-raw-posix.c
===================================================================

block-raw-posix.c +44 -65

198 lines not on this page · raw message

Modified: trunk/block-raw-win32.c
===================================================================

block-raw-win32.c +0 -13
@@ -339,19 +339,6 @@
     return 0;
 }
 
-void qemu_aio_init(void)
-{
-}
-
-void qemu_aio_flush(void)
-{
-}
-
-void qemu_aio_wait(void)
-{
-    qemu_bh_poll();
-}
-
 BlockDriver bdrv_raw = {
     "raw",
     sizeof(BDRVRawState),

Modified: trunk/block.c
===================================================================

block.c +0 -2
@@ -1310,8 +1310,6 @@
     bdrv_register(&bdrv_qcow2);
     bdrv_register(&bdrv_parallels);
     bdrv_register(&bdrv_nbd);
-
-    qemu_aio_init();
 }
 
 void *qemu_aio_get(BlockDriverState *bs, BlockDriverCompletionFunc *cb,

Modified: trunk/block.h
===================================================================

block.h +2 -4
@@ -1,6 +1,8 @@
 #ifndef BLOCK_H
 #define BLOCK_H
 
+#include "qemu-aio.h"
+
 /* block.c */
 typedef struct BlockDriver BlockDriver;
 
@@ -87,10 +89,6 @@
                                  BlockDriverCompletionFunc *cb, void *opaque);
 void bdrv_aio_cancel(BlockDriverAIOCB *acb);
 
-void qemu_aio_init(void);
-void qemu_aio_flush(void);
-void qemu_aio_wait(void);
-
 int qemu_key_check(BlockDriverState *bs, const char *name);
 
 /* Ensure contents are flushed to disk.  */

Added: trunk/qemu-aio.h
===================================================================

qemu-aio.h +45 -0

45 lines not on this page · raw message

#1 lore raw
Quoted 9 lines · Anthony Liguori

Revision: 5297

          http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=5297
Author:   aliguori
Date:     2008-09-22 19:17:18 +0000 (Mon, 22 Sep 2008)

Log Message:
-----------
Refactor AIO to allow multiple AIO implementations

This patch touches a lot. I've tested it quite a bit and posted a few versions at this point. I think it works pretty well but if anyone is testing (especially on non-Linux Unixes) and something seems wrong that's IO related, let me know.

Regards,

Anthony Liguori