[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PULL 19/27] block/qed: use buffer-based io
From: |
Kevin Wolf |
Subject: |
[Qemu-block] [PULL 19/27] block/qed: use buffer-based io |
Date: |
Tue, 30 Apr 2019 17:42:36 +0200 |
From: Vladimir Sementsov-Ogievskiy <address@hidden>
Move to _co_ versions of io functions qed_read_table() and
qed_write_table(), as we use qemu_co_mutex_unlock()
anyway.
Signed-off-by: Vladimir Sementsov-Ogievskiy <address@hidden>
Reviewed-by: Stefan Hajnoczi <address@hidden>
Reviewed-by: Stefano Garzarella <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
block/qed-table.c | 12 +++++-------
block/qed.c | 6 ++----
2 files changed, 7 insertions(+), 11 deletions(-)
diff --git a/block/qed-table.c b/block/qed-table.c
index c497bd4aec..cf30edd977 100644
--- a/block/qed-table.c
+++ b/block/qed-table.c
@@ -21,22 +21,22 @@
/* Called with table_lock held. */
static int qed_read_table(BDRVQEDState *s, uint64_t offset, QEDTable *table)
{
- QEMUIOVector qiov = QEMU_IOVEC_INIT_BUF(
- qiov, table->offsets, s->header.cluster_size * s->header.table_size);
+ unsigned int bytes = s->header.cluster_size * s->header.table_size;
+
int noffsets;
int i, ret;
trace_qed_read_table(s, offset, table);
qemu_co_mutex_unlock(&s->table_lock);
- ret = bdrv_preadv(s->bs->file, offset, &qiov);
+ ret = bdrv_co_pread(s->bs->file, offset, bytes, table->offsets, 0);
qemu_co_mutex_lock(&s->table_lock);
if (ret < 0) {
goto out;
}
/* Byteswap offsets */
- noffsets = qiov.size / sizeof(uint64_t);
+ noffsets = bytes / sizeof(uint64_t);
for (i = 0; i < noffsets; i++) {
table->offsets[i] = le64_to_cpu(table->offsets[i]);
}
@@ -66,7 +66,6 @@ static int qed_write_table(BDRVQEDState *s, uint64_t offset,
QEDTable *table,
unsigned int sector_mask = BDRV_SECTOR_SIZE / sizeof(uint64_t) - 1;
unsigned int start, end, i;
QEDTable *new_table;
- QEMUIOVector qiov;
size_t len_bytes;
int ret;
@@ -79,7 +78,6 @@ static int qed_write_table(BDRVQEDState *s, uint64_t offset,
QEDTable *table,
len_bytes = (end - start) * sizeof(uint64_t);
new_table = qemu_blockalign(s->bs, len_bytes);
- qemu_iovec_init_buf(&qiov, new_table->offsets, len_bytes);
/* Byteswap table */
for (i = start; i < end; i++) {
@@ -91,7 +89,7 @@ static int qed_write_table(BDRVQEDState *s, uint64_t offset,
QEDTable *table,
offset += start * sizeof(uint64_t);
qemu_co_mutex_unlock(&s->table_lock);
- ret = bdrv_pwritev(s->bs->file, offset, &qiov);
+ ret = bdrv_co_pwrite(s->bs->file, offset, len_bytes, new_table->offsets,
0);
qemu_co_mutex_lock(&s->table_lock);
trace_qed_write_table_cb(s, table, flush, ret);
if (ret < 0) {
diff --git a/block/qed.c b/block/qed.c
index 89af05d524..912edaf56a 100644
--- a/block/qed.c
+++ b/block/qed.c
@@ -113,15 +113,13 @@ static int coroutine_fn qed_write_header(BDRVQEDState *s)
int nsectors = DIV_ROUND_UP(sizeof(QEDHeader), BDRV_SECTOR_SIZE);
size_t len = nsectors * BDRV_SECTOR_SIZE;
uint8_t *buf;
- QEMUIOVector qiov;
int ret;
assert(s->allocating_acb || s->allocating_write_reqs_plugged);
buf = qemu_blockalign(s->bs, len);
- qemu_iovec_init_buf(&qiov, buf, len);
- ret = bdrv_co_preadv(s->bs->file, 0, qiov.size, &qiov, 0);
+ ret = bdrv_co_pread(s->bs->file, 0, len, buf, 0);
if (ret < 0) {
goto out;
}
@@ -129,7 +127,7 @@ static int coroutine_fn qed_write_header(BDRVQEDState *s)
/* Update header */
qed_header_cpu_to_le(&s->header, (QEDHeader *) buf);
- ret = bdrv_co_pwritev(s->bs->file, 0, qiov.size, &qiov, 0);
+ ret = bdrv_co_pwrite(s->bs->file, 0, len, buf, 0);
if (ret < 0) {
goto out;
}
--
2.20.1
- [Qemu-block] [PULL 12/27] iotests: Perform the correct test in 082, (continued)
- [Qemu-block] [PULL 12/27] iotests: Perform the correct test in 082, Kevin Wolf, 2019/04/30
- [Qemu-block] [PULL 14/27] qcow2: Fix qcow2_make_empty() with external data file, Kevin Wolf, 2019/04/30
- [Qemu-block] [PULL 15/27] qcow2: Fix error handling in the compression code, Kevin Wolf, 2019/04/30
- [Qemu-block] [PULL 16/27] block: introduce byte-based io helpers, Kevin Wolf, 2019/04/30
- [Qemu-block] [PULL 13/27] qemu-img: Make create hint at protocol options, Kevin Wolf, 2019/04/30
- [Qemu-block] [PULL 20/27] block/parallels: use buffer-based io, Kevin Wolf, 2019/04/30
- [Qemu-block] [PULL 23/27] block/stream: use buffer-based io, Kevin Wolf, 2019/04/30
- [Qemu-block] [PULL 17/27] block/qcow2: use buffer-based io, Kevin Wolf, 2019/04/30
- [Qemu-block] [PULL 18/27] block/qcow: use buffer-based io, Kevin Wolf, 2019/04/30
- [Qemu-block] [PULL 21/27] block/backup: use buffer-based io, Kevin Wolf, 2019/04/30
- [Qemu-block] [PULL 19/27] block/qed: use buffer-based io,
Kevin Wolf <=
- [Qemu-block] [PULL 25/27] commit: Make base read-only if there is an early failure, Kevin Wolf, 2019/04/30
- [Qemu-block] [PULL 24/27] qemu-img: use buffer-based io, Kevin Wolf, 2019/04/30
- [Qemu-block] [PULL 22/27] block/commit: use buffer-based io, Kevin Wolf, 2019/04/30
- [Qemu-block] [PULL 26/27] iotests: Check that images are in read-only mode after block-commit, Kevin Wolf, 2019/04/30
- [Qemu-block] [PULL 27/27] block/qed: add missed coroutine_fn markers, Kevin Wolf, 2019/04/30
- Re: [Qemu-block] [Qemu-devel] [PULL 00/27] Block layer patches, Peter Maydell, 2019/04/30