diff mbox

[v2,10/13] raw-posix: Convert to bdrv_co_pwrite_zeroes()

Message ID 1464815413-613-11-git-send-email-eblake@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Eric Blake June 1, 2016, 9:10 p.m. UTC
Another step on our continuing quest to switch to byte-based
interfaces.

Signed-off-by: Eric Blake <eblake@redhat.com>
---
 block/raw-posix.c | 34 +++++++++++++++++-----------------
 trace-events      |  2 +-
 2 files changed, 18 insertions(+), 18 deletions(-)

Comments

Kevin Wolf June 3, 2016, 4:21 p.m. UTC | #1
Am 01.06.2016 um 23:10 hat Eric Blake geschrieben:
> Another step on our continuing quest to switch to byte-based
> interfaces.
> 
> Signed-off-by: Eric Blake <eblake@redhat.com>
> ---
>  block/raw-posix.c | 34 +++++++++++++++++-----------------
>  trace-events      |  2 +-
>  2 files changed, 18 insertions(+), 18 deletions(-)
> 
> diff --git a/block/raw-posix.c b/block/raw-posix.c
> index a4f5a1b..8bfcb4a 100644
> --- a/block/raw-posix.c
> +++ b/block/raw-posix.c
> @@ -1252,8 +1252,8 @@ static int aio_worker(void *arg)
>  }
> 
>  static int paio_submit_co(BlockDriverState *bs, int fd,
> -        int64_t sector_num, QEMUIOVector *qiov, int nb_sectors,
> -        int type)
> +                          int64_t offset, QEMUIOVector *qiov,
> +                          int count, int type)
>  {
>      RawPosixAIOData *acb = g_new(RawPosixAIOData, 1);
>      ThreadPool *pool;
> @@ -1262,16 +1262,16 @@ static int paio_submit_co(BlockDriverState *bs, int fd,
>      acb->aio_type = type;
>      acb->aio_fildes = fd;
> 
> -    acb->aio_nbytes = nb_sectors * BDRV_SECTOR_SIZE;
> -    acb->aio_offset = sector_num * BDRV_SECTOR_SIZE;
> +    acb->aio_nbytes = count;
> +    acb->aio_offset = offset;
> 
>      if (qiov) {
>          acb->aio_iov = qiov->iov;
>          acb->aio_niov = qiov->niov;
> -        assert(qiov->size == acb->aio_nbytes);
> +        assert(qiov->size == count);
>      }
> 
> -    trace_paio_submit_co(sector_num, nb_sectors, type);
> +    trace_paio_submit_co(offset, qiov->size, type);

As discussed on IRC, I'm fixing this up in my branch with
s/qiov->size/count/ because qiov can be NULL.

This fixes qemu-iotests 048 for raw.

>      pool = aio_get_thread_pool(bdrv_get_aio_context(bs));
>      return thread_pool_submit_co(pool, aio_worker, acb);
>  }

Kevin
diff mbox

Patch

diff --git a/block/raw-posix.c b/block/raw-posix.c
index a4f5a1b..8bfcb4a 100644
--- a/block/raw-posix.c
+++ b/block/raw-posix.c
@@ -1252,8 +1252,8 @@  static int aio_worker(void *arg)
 }

 static int paio_submit_co(BlockDriverState *bs, int fd,
-        int64_t sector_num, QEMUIOVector *qiov, int nb_sectors,
-        int type)
+                          int64_t offset, QEMUIOVector *qiov,
+                          int count, int type)
 {
     RawPosixAIOData *acb = g_new(RawPosixAIOData, 1);
     ThreadPool *pool;
@@ -1262,16 +1262,16 @@  static int paio_submit_co(BlockDriverState *bs, int fd,
     acb->aio_type = type;
     acb->aio_fildes = fd;

-    acb->aio_nbytes = nb_sectors * BDRV_SECTOR_SIZE;
-    acb->aio_offset = sector_num * BDRV_SECTOR_SIZE;
+    acb->aio_nbytes = count;
+    acb->aio_offset = offset;

     if (qiov) {
         acb->aio_iov = qiov->iov;
         acb->aio_niov = qiov->niov;
-        assert(qiov->size == acb->aio_nbytes);
+        assert(qiov->size == count);
     }

-    trace_paio_submit_co(sector_num, nb_sectors, type);
+    trace_paio_submit_co(offset, qiov->size, type);
     pool = aio_get_thread_pool(bdrv_get_aio_context(bs));
     return thread_pool_submit_co(pool, aio_worker, acb);
 }
@@ -1868,17 +1868,17 @@  static coroutine_fn BlockAIOCB *raw_aio_discard(BlockDriverState *bs,
                        cb, opaque, QEMU_AIO_DISCARD);
 }

-static int coroutine_fn raw_co_write_zeroes(
-    BlockDriverState *bs, int64_t sector_num,
-    int nb_sectors, BdrvRequestFlags flags)
+static int coroutine_fn raw_co_pwrite_zeroes(
+    BlockDriverState *bs, int64_t offset,
+    int count, BdrvRequestFlags flags)
 {
     BDRVRawState *s = bs->opaque;

     if (!(flags & BDRV_REQ_MAY_UNMAP)) {
-        return paio_submit_co(bs, s->fd, sector_num, NULL, nb_sectors,
+        return paio_submit_co(bs, s->fd, offset, NULL, count,
                               QEMU_AIO_WRITE_ZEROES);
     } else if (s->discard_zeroes) {
-        return paio_submit_co(bs, s->fd, sector_num, NULL, nb_sectors,
+        return paio_submit_co(bs, s->fd, offset, NULL, count,
                               QEMU_AIO_DISCARD);
     }
     return -ENOTSUP;
@@ -1931,7 +1931,7 @@  BlockDriver bdrv_file = {
     .bdrv_create = raw_create,
     .bdrv_has_zero_init = bdrv_has_zero_init_1,
     .bdrv_co_get_block_status = raw_co_get_block_status,
-    .bdrv_co_write_zeroes = raw_co_write_zeroes,
+    .bdrv_co_pwrite_zeroes = raw_co_pwrite_zeroes,

     .bdrv_aio_readv = raw_aio_readv,
     .bdrv_aio_writev = raw_aio_writev,
@@ -2293,8 +2293,8 @@  static coroutine_fn BlockAIOCB *hdev_aio_discard(BlockDriverState *bs,
                        cb, opaque, QEMU_AIO_DISCARD|QEMU_AIO_BLKDEV);
 }

-static coroutine_fn int hdev_co_write_zeroes(BlockDriverState *bs,
-    int64_t sector_num, int nb_sectors, BdrvRequestFlags flags)
+static coroutine_fn int hdev_co_pwrite_zeroes(BlockDriverState *bs,
+    int64_t offset, int count, BdrvRequestFlags flags)
 {
     BDRVRawState *s = bs->opaque;
     int rc;
@@ -2304,10 +2304,10 @@  static coroutine_fn int hdev_co_write_zeroes(BlockDriverState *bs,
         return rc;
     }
     if (!(flags & BDRV_REQ_MAY_UNMAP)) {
-        return paio_submit_co(bs, s->fd, sector_num, NULL, nb_sectors,
+        return paio_submit_co(bs, s->fd, offset, NULL, count,
                               QEMU_AIO_WRITE_ZEROES|QEMU_AIO_BLKDEV);
     } else if (s->discard_zeroes) {
-        return paio_submit_co(bs, s->fd, sector_num, NULL, nb_sectors,
+        return paio_submit_co(bs, s->fd, offset, NULL, count,
                               QEMU_AIO_DISCARD|QEMU_AIO_BLKDEV);
     }
     return -ENOTSUP;
@@ -2379,7 +2379,7 @@  static BlockDriver bdrv_host_device = {
     .bdrv_reopen_abort   = raw_reopen_abort,
     .bdrv_create         = hdev_create,
     .create_opts         = &raw_create_opts,
-    .bdrv_co_write_zeroes = hdev_co_write_zeroes,
+    .bdrv_co_pwrite_zeroes = hdev_co_pwrite_zeroes,

     .bdrv_aio_readv	= raw_aio_readv,
     .bdrv_aio_writev	= raw_aio_writev,
diff --git a/trace-events b/trace-events
index 2537eec..7cdbc62 100644
--- a/trace-events
+++ b/trace-events
@@ -132,7 +132,7 @@  thread_pool_cancel(void *req, void *opaque) "req %p opaque %p"

 # block/raw-win32.c
 # block/raw-posix.c
-paio_submit_co(int64_t sector_num, int nb_sectors, int type) "sector_num %"PRId64" nb_sectors %d type %d"
+paio_submit_co(int64_t offset, int count, int type) "offset %"PRId64" count %d type %d"
 paio_submit(void *acb, void *opaque, int64_t sector_num, int nb_sectors, int type) "acb %p opaque %p sector_num %"PRId64" nb_sectors %d type %d"

 # ioport.c