[02/17] blkreplay: Convert to byte-based I/O
diff mbox

Message ID 1466500894-9710-3-git-send-email-kwolf@redhat.com
State New
Headers show

Commit Message

Kevin Wolf June 21, 2016, 9:21 a.m. UTC
The blkreplay driver only forwards the requests it gets, so converting
it to byte granularity is trivial.

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

Comments

Max Reitz June 22, 2016, 5:03 p.m. UTC | #1
On 21.06.2016 11:21, Kevin Wolf wrote:
> The blkreplay driver only forwards the requests it gets, so converting
> it to byte granularity is trivial.
> 
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
>  block/blkreplay.c | 16 ++++++++--------
>  1 file changed, 8 insertions(+), 8 deletions(-)

Reviewed-by: Max Reitz <mreitz@redhat.com>
Eric Blake June 22, 2016, 5:15 p.m. UTC | #2
On 06/21/2016 03:21 AM, Kevin Wolf wrote:
> The blkreplay driver only forwards the requests it gets, so converting
> it to byte granularity is trivial.
> 
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
>  block/blkreplay.c | 16 ++++++++--------
>  1 file changed, 8 insertions(+), 8 deletions(-)
> 

>  
> -static int coroutine_fn blkreplay_co_writev(BlockDriverState *bs,
> -    int64_t sector_num, int nb_sectors, QEMUIOVector *qiov)
> +static int coroutine_fn blkreplay_co_pwritev(BlockDriverState *bs,
> +    uint64_t offset, uint64_t bytes, QEMUIOVector *qiov, int flags)
>  {
>      uint64_t reqid = request_id++;
> -    int ret = bdrv_co_writev(bs->file->bs, sector_num, nb_sectors, qiov);
> +    int ret = bdrv_co_pwritev(bs->file->bs, offset, bytes, qiov, flags);

This would pass flags through, but fails to set .supported_write_flags,
so the caller will always pass flags=0. I think you want to set
.supported_write_flags during open; but see my recent patch about the
raw driver only setting flags according to the underlying device:

https://lists.gnu.org/archive/html/qemu-devel/2016-06/msg05823.html

Patch
diff mbox

diff --git a/block/blkreplay.c b/block/blkreplay.c
index 525c2d5..196b8d0 100755
--- a/block/blkreplay.c
+++ b/block/blkreplay.c
@@ -81,22 +81,22 @@  static void block_request_create(uint64_t reqid, BlockDriverState *bs,
     replay_block_event(req->bh, reqid);
 }
 
-static int coroutine_fn blkreplay_co_readv(BlockDriverState *bs,
-    int64_t sector_num, int nb_sectors, QEMUIOVector *qiov)
+static int coroutine_fn blkreplay_co_preadv(BlockDriverState *bs,
+    uint64_t offset, uint64_t bytes, QEMUIOVector *qiov, int flags)
 {
     uint64_t reqid = request_id++;
-    int ret = bdrv_co_readv(bs->file->bs, sector_num, nb_sectors, qiov);
+    int ret = bdrv_co_preadv(bs->file->bs, offset, bytes, qiov, flags);
     block_request_create(reqid, bs, qemu_coroutine_self());
     qemu_coroutine_yield();
 
     return ret;
 }
 
-static int coroutine_fn blkreplay_co_writev(BlockDriverState *bs,
-    int64_t sector_num, int nb_sectors, QEMUIOVector *qiov)
+static int coroutine_fn blkreplay_co_pwritev(BlockDriverState *bs,
+    uint64_t offset, uint64_t bytes, QEMUIOVector *qiov, int flags)
 {
     uint64_t reqid = request_id++;
-    int ret = bdrv_co_writev(bs->file->bs, sector_num, nb_sectors, qiov);
+    int ret = bdrv_co_pwritev(bs->file->bs, offset, bytes, qiov, flags);
     block_request_create(reqid, bs, qemu_coroutine_self());
     qemu_coroutine_yield();
 
@@ -144,8 +144,8 @@  static BlockDriver bdrv_blkreplay = {
     .bdrv_close             = blkreplay_close,
     .bdrv_getlength         = blkreplay_getlength,
 
-    .bdrv_co_readv          = blkreplay_co_readv,
-    .bdrv_co_writev         = blkreplay_co_writev,
+    .bdrv_co_preadv         = blkreplay_co_preadv,
+    .bdrv_co_pwritev        = blkreplay_co_pwritev,
 
     .bdrv_co_pwrite_zeroes  = blkreplay_co_pwrite_zeroes,
     .bdrv_co_discard        = blkreplay_co_discard,