Patchwork [v3,06/15] block: group together the plugging of synchronous IO emulation

login
register
mail settings
Submitter Paolo Bonzini
Date Oct. 5, 2011, 7:17 a.m.
Message ID <1317799065-29668-7-git-send-email-pbonzini@redhat.com>
Download mbox | patch
Permalink /patch/117760/
State New
Headers show

Comments

Paolo Bonzini - Oct. 5, 2011, 7:17 a.m.
This is duplicated twice for read/write operations.  Unify it, and
move it close to the code that adds bdrv_flush.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 block.c |   16 ++++++++--------
 1 files changed, 8 insertions(+), 8 deletions(-)

Patch

diff --git a/block.c b/block.c
index ce35dce..394ecaf 100644
--- a/block.c
+++ b/block.c
@@ -189,26 +189,26 @@  void bdrv_register(BlockDriver *bdrv)
         /* Emulate AIO by coroutines, and sync by AIO */
         bdrv->bdrv_aio_readv = bdrv_co_aio_readv_em;
         bdrv->bdrv_aio_writev = bdrv_co_aio_writev_em;
-        bdrv->bdrv_read = bdrv_read_em;
-        bdrv->bdrv_write = bdrv_write_em;
      } else {
         bdrv->bdrv_co_readv = bdrv_co_readv_em;
         bdrv->bdrv_co_writev = bdrv_co_writev_em;
-
         if (!bdrv->bdrv_aio_readv) {
             /* add AIO emulation layer */
             bdrv->bdrv_aio_readv = bdrv_aio_readv_em;
             bdrv->bdrv_aio_writev = bdrv_aio_writev_em;
-        } else if (!bdrv->bdrv_read) {
-            /* add synchronous IO emulation layer */
-            bdrv->bdrv_read = bdrv_read_em;
-            bdrv->bdrv_write = bdrv_write_em;
         }
     }
 
     if (!bdrv->bdrv_aio_flush) {
         bdrv->bdrv_aio_flush = bdrv_aio_flush_em;
-    } else if (!bdrv->bdrv_flush) {
+    }
+
+    /* add synchronous IO emulation layer */
+    if (!bdrv->bdrv_read) {
+        bdrv->bdrv_read = bdrv_read_em;
+        bdrv->bdrv_write = bdrv_write_em;
+    }
+    if (!bdrv->bdrv_flush) {
         bdrv->bdrv_flush = bdrv_flush_em;
     }