[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PULL 32/61] qed: Remove callback from qed_copy_from_backin
From: |
Kevin Wolf |
Subject: |
[Qemu-block] [PULL 32/61] qed: Remove callback from qed_copy_from_backing_file() |
Date: |
Fri, 23 Jun 2017 18:21:30 +0200 |
With this change, qed_aio_write_prefill() and qed_aio_write_postfill()
collapse into a single function. This is reflected by a rename of the
combined function to qed_aio_write_cow().
Signed-off-by: Kevin Wolf <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Reviewed-by: Stefan Hajnoczi <address@hidden>
---
block/qed.c | 57 +++++++++++++++++++++++----------------------------------
1 file changed, 23 insertions(+), 34 deletions(-)
diff --git a/block/qed.c b/block/qed.c
index af53b8f..658b31b 100644
--- a/block/qed.c
+++ b/block/qed.c
@@ -861,13 +861,9 @@ static int qed_read_backing_file(BDRVQEDState *s, uint64_t
pos,
* @pos: Byte position in device
* @len: Number of bytes
* @offset: Byte offset in image file
- * @cb: Completion function
- * @opaque: User data for completion function
*/
-static void qed_copy_from_backing_file(BDRVQEDState *s, uint64_t pos,
- uint64_t len, uint64_t offset,
- BlockCompletionFunc *cb,
- void *opaque)
+static int qed_copy_from_backing_file(BDRVQEDState *s, uint64_t pos,
+ uint64_t len, uint64_t offset)
{
QEMUIOVector qiov;
QEMUIOVector *backing_qiov = NULL;
@@ -876,8 +872,7 @@ static void qed_copy_from_backing_file(BDRVQEDState *s,
uint64_t pos,
/* Skip copy entirely if there is no work to do */
if (len == 0) {
- cb(opaque, 0);
- return;
+ return 0;
}
iov = (struct iovec) {
@@ -906,7 +901,7 @@ static void qed_copy_from_backing_file(BDRVQEDState *s,
uint64_t pos,
ret = 0;
out:
qemu_vfree(iov.iov_base);
- cb(opaque, ret);
+ return ret;
}
/**
@@ -1133,42 +1128,36 @@ static void qed_aio_write_main(void *opaque, int ret)
}
/**
- * Populate back untouched region of new data cluster
+ * Populate untouched regions of new data cluster
*/
-static void qed_aio_write_postfill(void *opaque, int ret)
+static void qed_aio_write_cow(void *opaque, int ret)
{
QEDAIOCB *acb = opaque;
BDRVQEDState *s = acb_to_s(acb);
- uint64_t start = acb->cur_pos + acb->cur_qiov.size;
- uint64_t len =
- qed_start_of_cluster(s, start + s->header.cluster_size - 1) - start;
- uint64_t offset = acb->cur_cluster +
- qed_offset_into_cluster(s, acb->cur_pos) +
- acb->cur_qiov.size;
+ uint64_t start, len, offset;
+
+ /* Populate front untouched region of new data cluster */
+ start = qed_start_of_cluster(s, acb->cur_pos);
+ len = qed_offset_into_cluster(s, acb->cur_pos);
+ trace_qed_aio_write_prefill(s, acb, start, len, acb->cur_cluster);
+ ret = qed_copy_from_backing_file(s, start, len, acb->cur_cluster);
if (ret) {
qed_aio_complete(acb, ret);
return;
}
- trace_qed_aio_write_postfill(s, acb, start, len, offset);
- qed_copy_from_backing_file(s, start, len, offset,
- qed_aio_write_main, acb);
-}
+ /* Populate back untouched region of new data cluster */
+ start = acb->cur_pos + acb->cur_qiov.size;
+ len = qed_start_of_cluster(s, start + s->header.cluster_size - 1) - start;
+ offset = acb->cur_cluster +
+ qed_offset_into_cluster(s, acb->cur_pos) +
+ acb->cur_qiov.size;
-/**
- * Populate front untouched region of new data cluster
- */
-static void qed_aio_write_prefill(void *opaque, int ret)
-{
- QEDAIOCB *acb = opaque;
- BDRVQEDState *s = acb_to_s(acb);
- uint64_t start = qed_start_of_cluster(s, acb->cur_pos);
- uint64_t len = qed_offset_into_cluster(s, acb->cur_pos);
+ trace_qed_aio_write_postfill(s, acb, start, len, offset);
+ ret = qed_copy_from_backing_file(s, start, len, offset);
- trace_qed_aio_write_prefill(s, acb, start, len, acb->cur_cluster);
- qed_copy_from_backing_file(s, start, len, acb->cur_cluster,
- qed_aio_write_postfill, acb);
+ qed_aio_write_main(acb, ret);
}
/**
@@ -1236,7 +1225,7 @@ static void qed_aio_write_alloc(QEDAIOCB *acb, size_t len)
cb = qed_aio_write_zero_cluster;
} else {
- cb = qed_aio_write_prefill;
+ cb = qed_aio_write_cow;
acb->cur_cluster = qed_alloc_clusters(s, acb->cur_nclusters);
}
--
1.8.3.1
- [Qemu-block] [PULL 26/61] qed: Make qed_read_table() synchronous, (continued)
- [Qemu-block] [PULL 26/61] qed: Make qed_read_table() synchronous, Kevin Wolf, 2017/06/23
- [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 <=
- [Qemu-block] [PULL 34/61] qed: Remove callback from qed_write_header(), Kevin Wolf, 2017/06/23
- [Qemu-block] [PULL 37/61] qed: Remove callback from qed_write_table(), Kevin Wolf, 2017/06/23
- [Qemu-block] [PULL 38/61] qed: Make qed_aio_read_data() synchronous, Kevin Wolf, 2017/06/23
- [Qemu-block] [PULL 40/61] qed: Inline qed_commit_l2_update(), Kevin Wolf, 2017/06/23
- [Qemu-block] [PULL 39/61] qed: Make qed_aio_write_main() synchronous, Kevin Wolf, 2017/06/23
- [Qemu-block] [PULL 35/61] qed: Make qed_write_table() synchronous, Kevin Wolf, 2017/06/23
- [Qemu-block] [PULL 36/61] qed: Remove GenericCB, Kevin Wolf, 2017/06/23
- [Qemu-block] [PULL 42/61] qed: Add return value to qed_aio_write_l2_update(), Kevin Wolf, 2017/06/23
- [Qemu-block] [PULL 41/61] qed: Add return value to qed_aio_write_l1_update(), Kevin Wolf, 2017/06/23
- [Qemu-block] [PULL 47/61] qed: Remove ret argument from qed_aio_next_io(), Kevin Wolf, 2017/06/23