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, qemu-devel@nongnu.org
Subject: [Qemu-devel] [PULL 04/37] null: Switch to byte-based read/write
Date: Tue, 15 May 2018 17:40:00 +0200	[thread overview]
Message-ID: <20180515154033.19899-5-kwolf@redhat.com> (raw)
In-Reply-To: <20180515154033.19899-1-kwolf@redhat.com>

From: Eric Blake <eblake@redhat.com>

We are gradually moving away from sector-based interfaces, towards
byte-based.  Make the change for the last few sector-based callbacks
in the null-co and null-aio drivers.

Note that since the null driver does nothing on writes, it trivially
supports the BDRV_REQ_FUA flag (all writes have already landed to
the same bit-bucket without needing an extra flush call).  Also, since
the null driver does just as well with byte-based requests, we can
now avoid cycles wasted on read-modify-write by taking advantage of
the block layer now defaulting the alignment to 1 instead of 512.

Signed-off-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 block/null.c | 45 +++++++++++++++++++++++----------------------
 1 file changed, 23 insertions(+), 22 deletions(-)

diff --git a/block/null.c b/block/null.c
index 3944550f67..5d610fdfba 100644
--- a/block/null.c
+++ b/block/null.c
@@ -93,6 +93,7 @@ static int null_file_open(BlockDriverState *bs, QDict *options, int flags,
     }
     s->read_zeroes = qemu_opt_get_bool(opts, NULL_OPT_ZEROES, false);
     qemu_opts_del(opts);
+    bs->supported_write_flags = BDRV_REQ_FUA;
     return ret;
 }
 
@@ -116,22 +117,22 @@ static coroutine_fn int null_co_common(BlockDriverState *bs)
     return 0;
 }
 
-static coroutine_fn int null_co_readv(BlockDriverState *bs,
-                                      int64_t sector_num, int nb_sectors,
-                                      QEMUIOVector *qiov)
+static coroutine_fn int null_co_preadv(BlockDriverState *bs,
+                                       uint64_t offset, uint64_t bytes,
+                                       QEMUIOVector *qiov, int flags)
 {
     BDRVNullState *s = bs->opaque;
 
     if (s->read_zeroes) {
-        qemu_iovec_memset(qiov, 0, 0, nb_sectors * BDRV_SECTOR_SIZE);
+        qemu_iovec_memset(qiov, 0, 0, bytes);
     }
 
     return null_co_common(bs);
 }
 
-static coroutine_fn int null_co_writev(BlockDriverState *bs,
-                                       int64_t sector_num, int nb_sectors,
-                                       QEMUIOVector *qiov)
+static coroutine_fn int null_co_pwritev(BlockDriverState *bs,
+                                        uint64_t offset, uint64_t bytes,
+                                        QEMUIOVector *qiov, int flags)
 {
     return null_co_common(bs);
 }
@@ -186,26 +187,26 @@ static inline BlockAIOCB *null_aio_common(BlockDriverState *bs,
     return &acb->common;
 }
 
-static BlockAIOCB *null_aio_readv(BlockDriverState *bs,
-                                  int64_t sector_num, QEMUIOVector *qiov,
-                                  int nb_sectors,
-                                  BlockCompletionFunc *cb,
-                                  void *opaque)
+static BlockAIOCB *null_aio_preadv(BlockDriverState *bs,
+                                   uint64_t offset, uint64_t bytes,
+                                   QEMUIOVector *qiov, int flags,
+                                   BlockCompletionFunc *cb,
+                                   void *opaque)
 {
     BDRVNullState *s = bs->opaque;
 
     if (s->read_zeroes) {
-        qemu_iovec_memset(qiov, 0, 0, nb_sectors * BDRV_SECTOR_SIZE);
+        qemu_iovec_memset(qiov, 0, 0, bytes);
     }
 
     return null_aio_common(bs, cb, opaque);
 }
 
-static BlockAIOCB *null_aio_writev(BlockDriverState *bs,
-                                   int64_t sector_num, QEMUIOVector *qiov,
-                                   int nb_sectors,
-                                   BlockCompletionFunc *cb,
-                                   void *opaque)
+static BlockAIOCB *null_aio_pwritev(BlockDriverState *bs,
+                                    uint64_t offset, uint64_t bytes,
+                                    QEMUIOVector *qiov, int flags,
+                                    BlockCompletionFunc *cb,
+                                    void *opaque)
 {
     return null_aio_common(bs, cb, opaque);
 }
@@ -265,8 +266,8 @@ static BlockDriver bdrv_null_co = {
     .bdrv_close             = null_close,
     .bdrv_getlength         = null_getlength,
 
-    .bdrv_co_readv          = null_co_readv,
-    .bdrv_co_writev         = null_co_writev,
+    .bdrv_co_preadv         = null_co_preadv,
+    .bdrv_co_pwritev        = null_co_pwritev,
     .bdrv_co_flush_to_disk  = null_co_flush,
     .bdrv_reopen_prepare    = null_reopen_prepare,
 
@@ -285,8 +286,8 @@ static BlockDriver bdrv_null_aio = {
     .bdrv_close             = null_close,
     .bdrv_getlength         = null_getlength,
 
-    .bdrv_aio_readv         = null_aio_readv,
-    .bdrv_aio_writev        = null_aio_writev,
+    .bdrv_aio_preadv        = null_aio_preadv,
+    .bdrv_aio_pwritev       = null_aio_pwritev,
     .bdrv_aio_flush         = null_aio_flush,
     .bdrv_reopen_prepare    = null_reopen_prepare,
 
-- 
2.13.6

  parent reply	other threads:[~2018-05-15 15:40 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-15 15:39 [Qemu-devel] [PULL 00/37] Block layer patches Kevin Wolf
2018-05-15 15:39 ` [Qemu-devel] [PULL 01/37] block-backend: simplify blk_get_aio_context Kevin Wolf
2018-05-15 15:39 ` [Qemu-devel] [PULL 02/37] block: Support byte-based aio callbacks Kevin Wolf
2018-05-15 15:39 ` [Qemu-devel] [PULL 03/37] file-win32: Switch to byte-based callbacks Kevin Wolf
2018-05-15 15:40 ` Kevin Wolf [this message]
2018-05-15 15:40 ` [Qemu-devel] [PULL 05/37] rbd: " Kevin Wolf
2018-05-15 15:40 ` [Qemu-devel] [PULL 06/37] vxhs: " Kevin Wolf
2018-05-15 15:40 ` [Qemu-devel] [PULL 07/37] block: Drop last of the sector-based aio callbacks Kevin Wolf
2018-05-15 15:40 ` [Qemu-devel] [PULL 08/37] block: Merge .bdrv_co_writev{, _flags} in drivers Kevin Wolf
2018-05-15 15:40 ` [Qemu-devel] [PULL 09/37] hmp: Allow using a qdev id in block_set_io_throttle Kevin Wolf
2018-05-15 15:40 ` [Qemu-devel] [PULL 10/37] blockjob: expose error string via query Kevin Wolf
2018-05-15 15:40 ` [Qemu-devel] [PULL 11/37] blockjob: Fix assertion in block_job_finalize() Kevin Wolf
2018-05-15 15:40 ` [Qemu-devel] [PULL 12/37] blockjob: Wrappers for progress counter access Kevin Wolf
2018-05-15 15:40 ` [Qemu-devel] [PULL 13/37] blockjob: Move RateLimit to BlockJob Kevin Wolf
2018-05-15 15:40 ` [Qemu-devel] [PULL 14/37] blockjob: Implement block_job_set_speed() centrally Kevin Wolf
2018-05-15 15:40 ` [Qemu-devel] [PULL 15/37] blockjob: Introduce block_job_ratelimit_get_delay() Kevin Wolf
2018-05-15 15:40 ` [Qemu-devel] [PULL 16/37] blockjob: Add block_job_driver() Kevin Wolf
2018-05-15 15:40 ` [Qemu-devel] [PULL 17/37] iotests: Split 214 off of 122 Kevin Wolf
2018-05-15 15:40 ` [Qemu-devel] [PULL 18/37] Fix error message about compressed clusters with OFLAG_COPIED Kevin Wolf
2018-05-15 15:40 ` [Qemu-devel] [PULL 19/37] specs/qcow2: Clarify that compressed clusters have the COPIED bit reset Kevin Wolf
2018-05-15 15:40 ` [Qemu-devel] [PULL 20/37] qcow2: Give the refcount cache the minimum possible size by default Kevin Wolf
2018-05-25 17:10   ` Peter Maydell
2018-05-28  8:38     ` Kevin Wolf
2018-05-28  8:58       ` Alberto Garcia
2018-05-28 13:49         ` Peter Maydell
2018-05-28 13:58           ` Alberto Garcia
2018-05-15 15:40 ` [Qemu-devel] [PULL 21/37] docs: Document the new default sizes of the qcow2 caches Kevin Wolf
2018-05-15 15:40 ` [Qemu-devel] [PULL 22/37] iotests: Add failure matching to common.qemu Kevin Wolf
2018-05-15 15:40 ` [Qemu-devel] [PULL 23/37] iotests: Skip 181 and 201 without userfaultfd Kevin Wolf
2018-05-15 15:40 ` [Qemu-devel] [PULL 24/37] block: Add COR filter driver Kevin Wolf
2018-05-15 15:40 ` [Qemu-devel] [PULL 25/37] block: BLK_PERM_WRITE includes ..._UNCHANGED Kevin Wolf
2018-05-15 15:40 ` [Qemu-devel] [PULL 26/37] block: Add BDRV_REQ_WRITE_UNCHANGED flag Kevin Wolf
2018-05-15 15:40 ` [Qemu-devel] [PULL 27/37] block: Set BDRV_REQ_WRITE_UNCHANGED for COR writes Kevin Wolf
2018-05-15 15:40 ` [Qemu-devel] [PULL 28/37] block/quorum: Support BDRV_REQ_WRITE_UNCHANGED Kevin Wolf
2018-05-15 15:40 ` [Qemu-devel] [PULL 29/37] block: Support BDRV_REQ_WRITE_UNCHANGED in filters Kevin Wolf
2018-05-15 15:40 ` [Qemu-devel] [PULL 30/37] iotests: Clean up wrap image in 197 Kevin Wolf
2018-05-15 15:40 ` [Qemu-devel] [PULL 31/37] iotests: Copy 197 for COR filter driver Kevin Wolf
2018-05-15 15:40 ` [Qemu-devel] [PULL 32/37] iotests: Add test for COR across nodes Kevin Wolf
2018-05-15 15:40 ` [Qemu-devel] [PULL 33/37] qemu-img: Check post-truncation size Kevin Wolf
2018-05-15 15:40 ` [Qemu-devel] [PULL 34/37] block: Document BDRV_REQ_WRITE_UNCHANGED support Kevin Wolf
2018-05-15 15:40 ` [Qemu-devel] [PULL 35/37] qemu-io: Use purely string blockdev options Kevin Wolf
2018-05-15 15:40 ` [Qemu-devel] [PULL 36/37] qemu-img: Use only string options in img_open_opts Kevin Wolf
2018-05-15 15:40 ` [Qemu-devel] [PULL 37/37] iotests: Add test for -U/force-share conflicts Kevin Wolf
2018-05-15 16:59 ` [Qemu-devel] [PULL 00/37] 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=20180515154033.19899-5-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 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).