qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: qemu-block@nongnu.org
Cc: kwolf@redhat.com, stefanha@redhat.com, famz@redhat.com,
	mreitz@redhat.com, jcody@redhat.com, qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 16/17] block: Convert bdrv_prwv_co() to BdrvChild
Date: Tue, 21 Jun 2016 11:21:33 +0200	[thread overview]
Message-ID: <1466500894-9710-17-git-send-email-kwolf@redhat.com> (raw)
In-Reply-To: <1466500894-9710-1-git-send-email-kwolf@redhat.com>

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 block/io.c | 37 +++++++++++++++++++++----------------
 1 file changed, 21 insertions(+), 16 deletions(-)

diff --git a/block/io.c b/block/io.c
index 641cd49..78529fc 100644
--- a/block/io.c
+++ b/block/io.c
@@ -557,7 +557,7 @@ static int bdrv_check_request(BlockDriverState *bs, int64_t sector_num,
 }
 
 typedef struct RwCo {
-    BlockDriverState *bs;
+    BdrvChild *child;
     int64_t offset;
     QEMUIOVector *qiov;
     bool is_write;
@@ -570,11 +570,11 @@ static void coroutine_fn bdrv_rw_co_entry(void *opaque)
     RwCo *rwco = opaque;
 
     if (!rwco->is_write) {
-        rwco->ret = bdrv_co_preadv(rwco->bs, rwco->offset,
+        rwco->ret = bdrv_co_preadv(rwco->child->bs, rwco->offset,
                                    rwco->qiov->size, rwco->qiov,
                                    rwco->flags);
     } else {
-        rwco->ret = bdrv_co_pwritev(rwco->bs, rwco->offset,
+        rwco->ret = bdrv_co_pwritev(rwco->child->bs, rwco->offset,
                                     rwco->qiov->size, rwco->qiov,
                                     rwco->flags);
     }
@@ -583,13 +583,13 @@ static void coroutine_fn bdrv_rw_co_entry(void *opaque)
 /*
  * Process a vectored synchronous request using coroutines
  */
-static int bdrv_prwv_co(BlockDriverState *bs, int64_t offset,
+static int bdrv_prwv_co(BdrvChild *child, int64_t offset,
                         QEMUIOVector *qiov, bool is_write,
                         BdrvRequestFlags flags)
 {
     Coroutine *co;
     RwCo rwco = {
-        .bs = bs,
+        .child = child,
         .offset = offset,
         .qiov = qiov,
         .is_write = is_write,
@@ -601,7 +601,7 @@ static int bdrv_prwv_co(BlockDriverState *bs, int64_t offset,
         /* Fast-path if already in coroutine context */
         bdrv_rw_co_entry(&rwco);
     } else {
-        AioContext *aio_context = bdrv_get_aio_context(bs);
+        AioContext *aio_context = bdrv_get_aio_context(child->bs);
 
         co = qemu_coroutine_create(bdrv_rw_co_entry);
         qemu_coroutine_enter(co, &rwco);
@@ -615,7 +615,7 @@ static int bdrv_prwv_co(BlockDriverState *bs, int64_t offset,
 /*
  * Process a synchronous request using coroutines
  */
-static int bdrv_rw_co(BlockDriverState *bs, int64_t sector_num, uint8_t *buf,
+static int bdrv_rw_co(BdrvChild *child, int64_t sector_num, uint8_t *buf,
                       int nb_sectors, bool is_write, BdrvRequestFlags flags)
 {
     QEMUIOVector qiov;
@@ -629,7 +629,7 @@ static int bdrv_rw_co(BlockDriverState *bs, int64_t sector_num, uint8_t *buf,
     }
 
     qemu_iovec_init_external(&qiov, &iov, 1);
-    return bdrv_prwv_co(bs, sector_num << BDRV_SECTOR_BITS,
+    return bdrv_prwv_co(child, sector_num << BDRV_SECTOR_BITS,
                         &qiov, is_write, flags);
 }
 
@@ -637,7 +637,7 @@ static int bdrv_rw_co(BlockDriverState *bs, int64_t sector_num, uint8_t *buf,
 int bdrv_read(BdrvChild *child, int64_t sector_num,
               uint8_t *buf, int nb_sectors)
 {
-    return bdrv_rw_co(child->bs, sector_num, buf, nb_sectors, false, 0);
+    return bdrv_rw_co(child, sector_num, buf, nb_sectors, false, 0);
 }
 
 /* Return < 0 if error. Important errors are:
@@ -649,8 +649,7 @@ int bdrv_read(BdrvChild *child, int64_t sector_num,
 int bdrv_write(BdrvChild *child, int64_t sector_num,
                const uint8_t *buf, int nb_sectors)
 {
-    return bdrv_rw_co(child->bs, sector_num, (uint8_t *)buf, nb_sectors,
-                      true, 0);
+    return bdrv_rw_co(child, sector_num, (uint8_t *)buf, nb_sectors, true, 0);
 }
 
 int bdrv_pwrite_zeroes(BdrvChild *child, int64_t offset,
@@ -663,7 +662,7 @@ int bdrv_pwrite_zeroes(BdrvChild *child, int64_t offset,
     };
 
     qemu_iovec_init_external(&qiov, &iov, 1);
-    return bdrv_prwv_co(child->bs, offset, &qiov, true,
+    return bdrv_prwv_co(child, offset, &qiov, true,
                         BDRV_REQ_ZERO_WRITE | flags);
 }
 
@@ -718,7 +717,7 @@ int bdrv_preadv(BdrvChild *child, int64_t offset, QEMUIOVector *qiov)
 {
     int ret;
 
-    ret = bdrv_prwv_co(child->bs, offset, qiov, false, 0);
+    ret = bdrv_prwv_co(child, offset, qiov, false, 0);
     if (ret < 0) {
         return ret;
     }
@@ -746,7 +745,7 @@ int bdrv_pwritev(BdrvChild *child, int64_t offset, QEMUIOVector *qiov)
 {
     int ret;
 
-    ret = bdrv_prwv_co(child->bs, offset, qiov, true, 0);
+    ret = bdrv_prwv_co(child, offset, qiov, true, 0);
     if (ret < 0) {
         return ret;
     }
@@ -2202,9 +2201,15 @@ void qemu_aio_unref(void *p)
 /**************************************************************/
 /* Coroutine block device emulation */
 
+typedef struct FlushCo {
+    BlockDriverState *bs;
+    int ret;
+} FlushCo;
+
+
 static void coroutine_fn bdrv_flush_co_entry(void *opaque)
 {
-    RwCo *rwco = opaque;
+    FlushCo *rwco = opaque;
 
     rwco->ret = bdrv_co_flush(rwco->bs);
 }
@@ -2288,7 +2293,7 @@ out:
 int bdrv_flush(BlockDriverState *bs)
 {
     Coroutine *co;
-    RwCo rwco = {
+    FlushCo rwco = {
         .bs = bs,
         .ret = NOT_DONE,
     };
-- 
1.8.3.1

  parent reply	other threads:[~2016-06-21  9:22 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-21  9:21 [Qemu-devel] [PATCH 00/17] block: Convert common I/O path to BdrvChild Kevin Wolf
2016-06-21  9:21 ` [Qemu-devel] [PATCH 01/17] vvfat: Use BdrvChild for s->qcow Kevin Wolf
2016-06-22 16:54   ` Max Reitz
2016-06-21  9:21 ` [Qemu-devel] [PATCH 02/17] blkreplay: Convert to byte-based I/O Kevin Wolf
2016-06-22 17:03   ` Max Reitz
2016-06-22 17:15   ` Eric Blake
2016-06-21  9:21 ` [Qemu-devel] [PATCH 03/17] vhdx: Some more BlockBackend use in vhdx_create() Kevin Wolf
2016-06-22 17:08   ` Max Reitz
2016-06-21  9:21 ` [Qemu-devel] [PATCH 04/17] block: Convert bdrv_co_readv() to BdrvChild Kevin Wolf
2016-06-25 15:07   ` Max Reitz
2016-06-21  9:21 ` [Qemu-devel] [PATCH 05/17] block: Convert bdrv_co_writev() " Kevin Wolf
2016-06-25 15:14   ` Max Reitz
2016-06-27  8:56     ` Kevin Wolf
2016-06-21  9:21 ` [Qemu-devel] [PATCH 06/17] block: Convert bdrv_aio_readv() " Kevin Wolf
2016-06-25 15:16   ` Max Reitz
2016-06-21  9:21 ` [Qemu-devel] [PATCH 07/17] block: Convert bdrv_aio_writev() " Kevin Wolf
2016-06-25 15:20   ` Max Reitz
2016-06-21  9:21 ` [Qemu-devel] [PATCH 08/17] block: Convert bdrv_co_do_readv/writev " Kevin Wolf
2016-06-25 15:26   ` Max Reitz
2016-06-21  9:21 ` [Qemu-devel] [PATCH 09/17] block: Move bdrv_commit() to block/commit.c Kevin Wolf
2016-06-24 15:37   ` Eric Blake
2016-06-21  9:21 ` [Qemu-devel] [PATCH 10/17] block: Use BlockBackend for I/O in bdrv_commit() Kevin Wolf
2016-06-25 15:34   ` Max Reitz
2016-06-21  9:21 ` [Qemu-devel] [PATCH 11/17] block: Convert bdrv_read() to BdrvChild Kevin Wolf
2016-06-27 13:24   ` Max Reitz
2016-06-21  9:21 ` [Qemu-devel] [PATCH 12/17] block: Convert bdrv_write() " Kevin Wolf
2016-06-27 13:44   ` Max Reitz
2016-06-27 13:47     ` Max Reitz
2016-06-29 12:11       ` [Qemu-devel] [PATCH v2 " Kevin Wolf
2016-06-29 15:22         ` Max Reitz
2016-06-29 15:33           ` Kevin Wolf
2016-06-29 15:37             ` Max Reitz
2016-06-21  9:21 ` [Qemu-devel] [PATCH 13/17] block: Convert bdrv_pread(v) " Kevin Wolf
2016-06-27 14:55   ` Max Reitz
2016-06-21  9:21 ` [Qemu-devel] [PATCH 14/17] block: Convert bdrv_pwrite(v/_sync) " Kevin Wolf
2016-06-27 15:07   ` Max Reitz
2016-06-21  9:21 ` [Qemu-devel] [PATCH 15/17] block: Convert bdrv_pwrite_zeroes() " Kevin Wolf
2016-06-27 15:12   ` Max Reitz
2016-06-21  9:21 ` Kevin Wolf [this message]
2016-06-27 15:19   ` [Qemu-devel] [PATCH 16/17] block: Convert bdrv_prwv_co() " Max Reitz
2016-06-21  9:21 ` [Qemu-devel] [PATCH 17/17] block: Convert bdrv_co_preadv/pwritev " Kevin Wolf
2016-06-21  9:47 ` [Qemu-devel] [PATCH 00/17] block: Convert common I/O path " Paolo Bonzini
2016-06-21 10:56   ` Kevin Wolf
2016-06-21 11:01     ` Paolo Bonzini
2016-06-21 11:31       ` Kevin Wolf
2016-06-22  8:37         ` Fam Zheng
2016-06-28 13:28 ` Stefan Hajnoczi
2016-06-29 11:58   ` Kevin Wolf

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=1466500894-9710-17-git-send-email-kwolf@redhat.com \
    --to=kwolf@redhat.com \
    --cc=famz@redhat.com \
    --cc=jcody@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /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).