All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: qemu-block@nongnu.org
Cc: kwolf@redhat.com, qemu-devel@nongnu.org
Subject: [Qemu-devel] [PULL 01/23] block: Use blk_co_flush() for all BB level flushes
Date: Thu, 27 Oct 2016 20:08:45 +0200	[thread overview]
Message-ID: <1477591747-21962-2-git-send-email-kwolf@redhat.com> (raw)
In-Reply-To: <1477591747-21962-1-git-send-email-kwolf@redhat.com>

All read/write functions already have a single coroutine-based function
on the BlockBackend level through which all requests go (no matter what
API style the external caller used) and which passes the requests down
to the block node level.

This patch extends this mode of operation to flushes.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
---
 block/block-backend.c | 27 +++++++++++++++++----------
 1 file changed, 17 insertions(+), 10 deletions(-)

diff --git a/block/block-backend.c b/block/block-backend.c
index 1a724a8..96bb634 100644
--- a/block/block-backend.c
+++ b/block/block-backend.c
@@ -1099,14 +1099,19 @@ BlockAIOCB *blk_aio_pwritev(BlockBackend *blk, int64_t offset,
                         blk_aio_write_entry, flags, cb, opaque);
 }
 
+static void blk_aio_flush_entry(void *opaque)
+{
+    BlkAioEmAIOCB *acb = opaque;
+    BlkRwCo *rwco = &acb->rwco;
+
+    rwco->ret = blk_co_flush(rwco->blk);
+    blk_aio_complete(acb);
+}
+
 BlockAIOCB *blk_aio_flush(BlockBackend *blk,
                           BlockCompletionFunc *cb, void *opaque)
 {
-    if (!blk_is_available(blk)) {
-        return blk_abort_aio_request(blk, cb, opaque, -ENOMEDIUM);
-    }
-
-    return bdrv_aio_flush(blk_bs(blk), cb, opaque);
+    return blk_aio_prwv(blk, 0, 0, NULL, blk_aio_flush_entry, 0, cb, opaque);
 }
 
 BlockAIOCB *blk_aio_pdiscard(BlockBackend *blk,
@@ -1169,13 +1174,15 @@ int blk_co_flush(BlockBackend *blk)
     return bdrv_co_flush(blk_bs(blk));
 }
 
-int blk_flush(BlockBackend *blk)
+static void blk_flush_entry(void *opaque)
 {
-    if (!blk_is_available(blk)) {
-        return -ENOMEDIUM;
-    }
+    BlkRwCo *rwco = opaque;
+    rwco->ret = blk_co_flush(rwco->blk);
+}
 
-    return bdrv_flush(blk_bs(blk));
+int blk_flush(BlockBackend *blk)
+{
+    return blk_prw(blk, 0, NULL, 0, blk_flush_entry, 0);
 }
 
 void blk_drain(BlockBackend *blk)
-- 
1.8.3.1

  reply	other threads:[~2016-10-27 18:09 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-27 18:08 [Qemu-devel] [PULL 00/23] Block layer patches Kevin Wolf
2016-10-27 18:08 ` Kevin Wolf [this message]
2016-10-27 18:08 ` [Qemu-devel] [PULL 02/23] block: Use blk_co_pdiscard() for all BB level discard Kevin Wolf
2016-10-27 18:08 ` [Qemu-devel] [PULL 03/23] block: Remove bdrv_aio_pdiscard() Kevin Wolf
2016-10-27 18:08 ` [Qemu-devel] [PULL 04/23] block: Use blk_co_ioctl() for all BB level ioctls Kevin Wolf
2016-10-27 18:08 ` [Qemu-devel] [PULL 05/23] raw-posix: Don't use bdrv_ioctl() Kevin Wolf
2016-10-27 18:08 ` [Qemu-devel] [PULL 06/23] block: Remove bdrv_ioctl() Kevin Wolf
2016-10-27 18:08 ` [Qemu-devel] [PULL 07/23] block: Introduce .bdrv_co_ioctl() driver callback Kevin Wolf
2016-10-27 18:08 ` [Qemu-devel] [PULL 08/23] raw: Implement .bdrv_co_ioctl instead of .bdrv_aio_ioctl Kevin Wolf
2016-10-27 18:08 ` [Qemu-devel] [PULL 09/23] block: Remove bdrv_aio_ioctl() Kevin Wolf
2016-10-27 18:08 ` [Qemu-devel] [PULL 10/23] qemu-iotests: Fix typo for NFS with IMGOPTSSYNTAX Kevin Wolf
2016-10-27 18:08 ` [Qemu-devel] [PULL 11/23] block/nbd: Drop trailing "." in error messages Kevin Wolf
2016-10-27 18:08 ` [Qemu-devel] [PULL 12/23] block/nbd: Reject port parameter without host Kevin Wolf
2016-10-27 18:08 ` [Qemu-devel] [PULL 13/23] block/nbd: Default port in nbd_refresh_filename() Kevin Wolf
2016-10-27 18:08 ` [Qemu-devel] [PULL 14/23] block/nbd: Use qdict_put() Kevin Wolf
2016-10-27 18:08 ` [Qemu-devel] [PULL 15/23] block/nbd: Add nbd_has_filename_options_conflict() Kevin Wolf
2016-10-27 18:09 ` [Qemu-devel] [PULL 16/23] block/nbd: Accept SocketAddress Kevin Wolf
2016-10-27 18:09 ` [Qemu-devel] [PULL 17/23] block/nbd: Use SocketAddress options Kevin Wolf
2016-10-27 18:09 ` [Qemu-devel] [PULL 18/23] qapi: Allow blockdev-add for NBD Kevin Wolf
2016-10-27 18:09 ` [Qemu-devel] [PULL 19/23] iotests.py: Add qemu_nbd function Kevin Wolf
2016-10-27 18:09 ` [Qemu-devel] [PULL 20/23] iotests.py: Allow concurrent qemu instances Kevin Wolf
2016-10-27 18:09 ` [Qemu-devel] [PULL 21/23] socket_scm_helper: Accept fd directly Kevin Wolf
2016-10-27 18:09 ` [Qemu-devel] [PULL 22/23] iotests: Add assert_json_filename_equal() method Kevin Wolf
2016-10-27 18:09 ` [Qemu-devel] [PULL 23/23] iotests: Add test for NBD's blockdev-add interface Kevin Wolf
2016-10-28 13:29 ` [Qemu-devel] [PULL 00/23] Block layer patches Peter Maydell

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=1477591747-21962-2-git-send-email-kwolf@redhat.com \
    --to=kwolf@redhat.com \
    --cc=qemu-block@nongnu.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.