[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 10/11] qemu-io-cmds: drop do_co_readv() and do_co_writev() helper
From: |
Vladimir Sementsov-Ogievskiy |
Subject: |
[PATCH 10/11] qemu-io-cmds: drop do_co_readv() and do_co_writev() helpers |
Date: |
Sat, 24 Apr 2021 00:40:32 +0300 |
They don't make much sense. Call blk_co_ functions directly and also
drop some redundant variables.
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
qemu-io-cmds.c | 38 ++++++--------------------------------
1 file changed, 6 insertions(+), 32 deletions(-)
diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c
index 2f0a27079d..9a0e5322de 100644
--- a/qemu-io-cmds.c
+++ b/qemu-io-cmds.c
@@ -527,24 +527,6 @@ fail:
return buf;
}
-static int coroutine_fn do_co_readv(BlockBackend *blk, QEMUIOVector *qiov,
- int64_t offset, int *total)
-{
- int ret = blk_co_preadv(blk, offset, qiov->size, qiov, 0);
-
- *total = qiov->size;
- return ret < 0 ? ret : 1;
-}
-
-static int coroutine_fn do_co_writev(BlockBackend *blk, QEMUIOVector *qiov,
- int64_t offset, int flags, int *total)
-{
- int ret = blk_co_pwritev(blk, offset, qiov->size, qiov, flags);
-
- *total = qiov->size;
- return ret < 0 ? ret : 1;
-}
-
static void read_help(void)
{
printf(
@@ -767,11 +749,10 @@ static int coroutine_fn readv_f(BlockBackend *blk, int
argc, char **argv)
{
struct timespec t1, t2;
bool Cflag = false, qflag = false, vflag = false;
- int c, cnt, ret;
+ int c, ret;
char *buf;
int64_t offset;
/* Some compilers get confused and warn if this is not initialized. */
- int total = 0;
int nr_iov;
QEMUIOVector qiov;
int pattern = 0;
@@ -821,16 +802,13 @@ static int coroutine_fn readv_f(BlockBackend *blk, int
argc, char **argv)
}
clock_gettime(CLOCK_MONOTONIC, &t1);
- ret = do_co_readv(blk, &qiov, offset, &total);
+ ret = blk_co_preadv(blk, offset, qiov.size, &qiov, 0);
clock_gettime(CLOCK_MONOTONIC, &t2);
if (ret < 0) {
printf("readv failed: %s\n", strerror(-ret));
goto out;
}
- cnt = ret;
-
- ret = 0;
if (Pflag) {
void *cmp_buf = g_malloc(qiov.size);
@@ -853,7 +831,7 @@ static int coroutine_fn readv_f(BlockBackend *blk, int
argc, char **argv)
/* Finally, report back -- -C gives a parsable format */
t2 = tsub(t2, t1);
- print_report("read", &t2, offset, qiov.size, total, cnt, Cflag);
+ print_report("read", &t2, offset, qiov.size, qiov.size, 1, Cflag);
out:
qemu_iovec_destroy(&qiov);
@@ -1100,11 +1078,10 @@ static int coroutine_fn writev_f(BlockBackend *blk, int
argc, char **argv)
struct timespec t1, t2;
bool Cflag = false, qflag = false;
int flags = 0;
- int c, cnt, ret;
+ int c, ret;
char *buf;
int64_t offset;
/* Some compilers get confused and warn if this is not initialized. */
- int total = 0;
int nr_iov;
int pattern = 0xcd;
QEMUIOVector qiov;
@@ -1151,16 +1128,13 @@ static int coroutine_fn writev_f(BlockBackend *blk, int
argc, char **argv)
}
clock_gettime(CLOCK_MONOTONIC, &t1);
- ret = do_co_writev(blk, &qiov, offset, flags, &total);
+ ret = blk_co_pwritev(blk, offset, qiov.size, &qiov, flags);
clock_gettime(CLOCK_MONOTONIC, &t2);
if (ret < 0) {
printf("writev failed: %s\n", strerror(-ret));
goto out;
}
- cnt = ret;
-
- ret = 0;
if (qflag) {
goto out;
@@ -1168,7 +1142,7 @@ static int coroutine_fn writev_f(BlockBackend *blk, int
argc, char **argv)
/* Finally, report back -- -C gives a parsable format */
t2 = tsub(t2, t1);
- print_report("wrote", &t2, offset, qiov.size, total, cnt, Cflag);
+ print_report("wrote", &t2, offset, qiov.size, qiov.size, 1, Cflag);
out:
qemu_iovec_destroy(&qiov);
qemu_io_free(buf);
--
2.29.2
- [PATCH 00/11] qemu-io-cmds: move to coroutine, Vladimir Sementsov-Ogievskiy, 2021/04/23
- [PATCH 01/11] block-coroutine-wrapper: allow non bdrv_ prefix, Vladimir Sementsov-Ogievskiy, 2021/04/23
- [PATCH 02/11] block-coroutine-wrapper: support BlockBackend first argument, Vladimir Sementsov-Ogievskiy, 2021/04/23
- [PATCH 03/11] block/block-gen.h: bind monitor, Vladimir Sementsov-Ogievskiy, 2021/04/23
- [PATCH 04/11] block: introduce bdrv_debug_wait_break, Vladimir Sementsov-Ogievskiy, 2021/04/23
- [PATCH 05/11] qemu-io-cmds: move qemu-io commands to coroutine, Vladimir Sementsov-Ogievskiy, 2021/04/23
- [PATCH 06/11] block: drop unused bdrv_debug_is_suspended(), Vladimir Sementsov-Ogievskiy, 2021/04/23
- [PATCH 07/11] block-backend: add _co_ versions of blk_save_vmstate / blk_load_vmstate, Vladimir Sementsov-Ogievskiy, 2021/04/23
- [PATCH 10/11] qemu-io-cmds: drop do_co_readv() and do_co_writev() helpers,
Vladimir Sementsov-Ogievskiy <=
- [PATCH 09/11] qemu-io-cmds: refactor write_f(): drop extra helpers and variables, Vladimir Sementsov-Ogievskiy, 2021/04/23
- [PATCH 08/11] qemu-io-cmds: refactor read_f(): drop extra helpers and variables, Vladimir Sementsov-Ogievskiy, 2021/04/23
- [PATCH 11/11] block-backend: drop unused blk_save_vmstate() and blk_load_vmstate(), Vladimir Sementsov-Ogievskiy, 2021/04/23