[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PULL 26/61] qed: Make qed_read_table() synchronous
From: |
Kevin Wolf |
Subject: |
[Qemu-block] [PULL 26/61] qed: Make qed_read_table() synchronous |
Date: |
Fri, 23 Jun 2017 18:21:24 +0200 |
Note that this code is generally not running in coroutine context, so
this is an actual blocking synchronous operation. We'll fix this in a
moment.
Signed-off-by: Kevin Wolf <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Reviewed-by: Stefan Hajnoczi <address@hidden>
---
block/qed-table.c | 56 ++++++++++++++++++-------------------------------------
1 file changed, 18 insertions(+), 38 deletions(-)
diff --git a/block/qed-table.c b/block/qed-table.c
index b12c298..f330538 100644
--- a/block/qed-table.c
+++ b/block/qed-table.c
@@ -18,59 +18,39 @@
#include "qed.h"
#include "qemu/bswap.h"
-typedef struct {
- GenericCB gencb;
- BDRVQEDState *s;
- QEDTable *table;
-
- struct iovec iov;
+static void qed_read_table(BDRVQEDState *s, uint64_t offset, QEDTable *table,
+ BlockCompletionFunc *cb, void *opaque)
+{
QEMUIOVector qiov;
-} QEDReadTableCB;
+ int noffsets;
+ int i, ret;
-static void qed_read_table_cb(void *opaque, int ret)
-{
- QEDReadTableCB *read_table_cb = opaque;
- QEDTable *table = read_table_cb->table;
- BDRVQEDState *s = read_table_cb->s;
- int noffsets = read_table_cb->qiov.size / sizeof(uint64_t);
- int i;
+ struct iovec iov = {
+ .iov_base = table->offsets,
+ .iov_len = s->header.cluster_size * s->header.table_size,
+ };
+ qemu_iovec_init_external(&qiov, &iov, 1);
- /* Handle I/O error */
- if (ret) {
+ trace_qed_read_table(s, offset, table);
+
+ ret = bdrv_preadv(s->bs->file, offset, &qiov);
+ if (ret < 0) {
goto out;
}
/* Byteswap offsets */
qed_acquire(s);
+ noffsets = qiov.size / sizeof(uint64_t);
for (i = 0; i < noffsets; i++) {
table->offsets[i] = le64_to_cpu(table->offsets[i]);
}
qed_release(s);
+ ret = 0;
out:
/* Completion */
- trace_qed_read_table_cb(s, read_table_cb->table, ret);
- gencb_complete(&read_table_cb->gencb, ret);
-}
-
-static void qed_read_table(BDRVQEDState *s, uint64_t offset, QEDTable *table,
- BlockCompletionFunc *cb, void *opaque)
-{
- QEDReadTableCB *read_table_cb = gencb_alloc(sizeof(*read_table_cb),
- cb, opaque);
- QEMUIOVector *qiov = &read_table_cb->qiov;
-
- trace_qed_read_table(s, offset, table);
-
- read_table_cb->s = s;
- read_table_cb->table = table;
- read_table_cb->iov.iov_base = table->offsets,
- read_table_cb->iov.iov_len = s->header.cluster_size * s->header.table_size,
-
- qemu_iovec_init_external(qiov, &read_table_cb->iov, 1);
- bdrv_aio_readv(s->bs->file, offset / BDRV_SECTOR_SIZE, qiov,
- qiov->size / BDRV_SECTOR_SIZE,
- qed_read_table_cb, read_table_cb);
+ trace_qed_read_table_cb(s, table, ret);
+ cb(opaque, ret);
}
typedef struct {
--
1.8.3.1
- [Qemu-block] [PULL 14/61] qemu-iotests: 068: use -drive/-device instead of -hda, (continued)
- [Qemu-block] [PULL 14/61] qemu-iotests: 068: use -drive/-device instead of -hda, Kevin Wolf, 2017/06/23
- [Qemu-block] [PULL 11/61] virtio-pci: use ioeventfd even when KVM is disabled, Kevin Wolf, 2017/06/23
- [Qemu-block] [PULL 15/61] qemu-iotests: 068: test iothread mode, Kevin Wolf, 2017/06/23
- [Qemu-block] [PULL 17/61] qcow2: Remove unused Error variable in do_perform_cow(), Kevin Wolf, 2017/06/23
- [Qemu-block] [PULL 18/61] qcow2: Use unsigned int for both members of Qcow2COWRegion, Kevin Wolf, 2017/06/23
- [Qemu-block] [PULL 20/61] qcow2: Split do_perform_cow() into _read(), _encrypt() and _write(), Kevin Wolf, 2017/06/23
- [Qemu-block] [PULL 16/61] nvme: Add support for Read Data and Write Data in CMBs., Kevin Wolf, 2017/06/23
- [Qemu-block] [PULL 19/61] qcow2: Make perform_cow() call do_perform_cow() twice, Kevin Wolf, 2017/06/23
- [Qemu-block] [PULL 21/61] qcow2: Allow reading both COW regions with only one request, Kevin Wolf, 2017/06/23
- [Qemu-block] [PULL 22/61] qcow2: Pass a QEMUIOVector to do_perform_cow_{read, write}(), Kevin Wolf, 2017/06/23
- [Qemu-block] [PULL 26/61] qed: Make qed_read_table() synchronous,
Kevin Wolf <=
- [Qemu-block] [PULL 24/61] qcow2: Use offset_into_cluster() and offset_to_l2_index(), Kevin Wolf, 2017/06/23
- [Qemu-block] [PULL 25/61] qed: Use bottom half to resume waiting requests, Kevin Wolf, 2017/06/23
- [Qemu-block] [PULL 27/61] qed: Remove callback from qed_read_table(), Kevin Wolf, 2017/06/23
- [Qemu-block] [PULL 23/61] qcow2: Merge the writing of the COW regions with the guest data, Kevin Wolf, 2017/06/23
- [Qemu-block] [PULL 28/61] qed: Remove callback from qed_read_l2_table(), Kevin Wolf, 2017/06/23
- [Qemu-block] [PULL 29/61] qed: Remove callback from qed_find_cluster(), Kevin Wolf, 2017/06/23
- [Qemu-block] [PULL 30/61] qed: Make qed_read_backing_file() synchronous, Kevin Wolf, 2017/06/23
- [Qemu-block] [PULL 31/61] qed: Make qed_copy_from_backing_file() synchronous, Kevin Wolf, 2017/06/23
- [Qemu-block] [PULL 33/61] qed: Make qed_write_header() synchronous, Kevin Wolf, 2017/06/23
- [Qemu-block] [PULL 32/61] qed: Remove callback from qed_copy_from_backing_file(), Kevin Wolf, 2017/06/23