[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 19/61] qcow2: Make perform_cow() call do_perform_cow(
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 19/61] qcow2: Make perform_cow() call do_perform_cow() twice |
Date: |
Fri, 23 Jun 2017 18:21:17 +0200 |
From: Alberto Garcia <address@hidden>
Instead of calling perform_cow() twice with a different COW region
each time, call it just once and make perform_cow() handle both
regions.
This patch simply moves code around. The next one will do the actual
reordering of the COW operations.
Signed-off-by: Alberto Garcia <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Reviewed-by: Kevin Wolf <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
block/qcow2-cluster.c | 36 ++++++++++++++++++++++--------------
1 file changed, 22 insertions(+), 14 deletions(-)
diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
index a86c5a7..4c03639 100644
--- a/block/qcow2-cluster.c
+++ b/block/qcow2-cluster.c
@@ -414,6 +414,10 @@ static int coroutine_fn do_perform_cow(BlockDriverState
*bs,
struct iovec iov;
int ret;
+ if (bytes == 0) {
+ return 0;
+ }
+
iov.iov_len = bytes;
iov.iov_base = qemu_try_blockalign(bs, iov.iov_len);
if (iov.iov_base == NULL) {
@@ -751,31 +755,40 @@ uint64_t
qcow2_alloc_compressed_cluster_offset(BlockDriverState *bs,
return cluster_offset;
}
-static int perform_cow(BlockDriverState *bs, QCowL2Meta *m, Qcow2COWRegion *r)
+static int perform_cow(BlockDriverState *bs, QCowL2Meta *m)
{
BDRVQcow2State *s = bs->opaque;
+ Qcow2COWRegion *start = &m->cow_start;
+ Qcow2COWRegion *end = &m->cow_end;
int ret;
- if (r->nb_bytes == 0) {
+ if (start->nb_bytes == 0 && end->nb_bytes == 0) {
return 0;
}
qemu_co_mutex_unlock(&s->lock);
- ret = do_perform_cow(bs, m->offset, m->alloc_offset, r->offset,
r->nb_bytes);
- qemu_co_mutex_lock(&s->lock);
-
+ ret = do_perform_cow(bs, m->offset, m->alloc_offset,
+ start->offset, start->nb_bytes);
if (ret < 0) {
- return ret;
+ goto fail;
}
+ ret = do_perform_cow(bs, m->offset, m->alloc_offset,
+ end->offset, end->nb_bytes);
+
+fail:
+ qemu_co_mutex_lock(&s->lock);
+
/*
* Before we update the L2 table to actually point to the new cluster, we
* need to be sure that the refcounts have been increased and COW was
* handled.
*/
- qcow2_cache_depends_on_flush(s->l2_table_cache);
+ if (ret == 0) {
+ qcow2_cache_depends_on_flush(s->l2_table_cache);
+ }
- return 0;
+ return ret;
}
int qcow2_alloc_cluster_link_l2(BlockDriverState *bs, QCowL2Meta *m)
@@ -795,12 +808,7 @@ int qcow2_alloc_cluster_link_l2(BlockDriverState *bs,
QCowL2Meta *m)
}
/* copy content of unmodified sectors */
- ret = perform_cow(bs, m, &m->cow_start);
- if (ret < 0) {
- goto err;
- }
-
- ret = perform_cow(bs, m, &m->cow_end);
+ ret = perform_cow(bs, m);
if (ret < 0) {
goto err;
}
--
1.8.3.1
- [Qemu-devel] [PULL 07/61] migration: use bdrv_drain_all_begin/end() instead bdrv_drain_all(), (continued)
- [Qemu-devel] [PULL 07/61] migration: use bdrv_drain_all_begin/end() instead bdrv_drain_all(), Kevin Wolf, 2017/06/23
- [Qemu-devel] [PULL 10/61] throttle: Update throttle-groups.c documentation, Kevin Wolf, 2017/06/23
- [Qemu-devel] [PULL 11/61] virtio-pci: use ioeventfd even when KVM is disabled, Kevin Wolf, 2017/06/23
- [Qemu-devel] [PULL 08/61] doc: Document generic -blockdev options, Kevin Wolf, 2017/06/23
- [Qemu-devel] [PULL 09/61] doc: Document driver-specific -blockdev options, Kevin Wolf, 2017/06/23
- [Qemu-devel] [PULL 12/61] migration: hold AioContext lock for loadvm qemu_fclose(), Kevin Wolf, 2017/06/23
- [Qemu-devel] [PULL 13/61] qemu-iotests: 068: extract _qemu() function, Kevin Wolf, 2017/06/23
- [Qemu-devel] [PULL 14/61] qemu-iotests: 068: use -drive/-device instead of -hda, Kevin Wolf, 2017/06/23
- [Qemu-devel] [PULL 15/61] qemu-iotests: 068: test iothread mode, Kevin Wolf, 2017/06/23
- [Qemu-devel] [PULL 17/61] qcow2: Remove unused Error variable in do_perform_cow(), Kevin Wolf, 2017/06/23
- [Qemu-devel] [PULL 19/61] qcow2: Make perform_cow() call do_perform_cow() twice,
Kevin Wolf <=
- [Qemu-devel] [PULL 16/61] nvme: Add support for Read Data and Write Data in CMBs., Kevin Wolf, 2017/06/23
- [Qemu-devel] [PULL 18/61] qcow2: Use unsigned int for both members of Qcow2COWRegion, Kevin Wolf, 2017/06/23
- [Qemu-devel] [PULL 20/61] qcow2: Split do_perform_cow() into _read(), _encrypt() and _write(), Kevin Wolf, 2017/06/23
- [Qemu-devel] [PULL 22/61] qcow2: Pass a QEMUIOVector to do_perform_cow_{read, write}(), Kevin Wolf, 2017/06/23
- [Qemu-devel] [PULL 21/61] qcow2: Allow reading both COW regions with only one request, Kevin Wolf, 2017/06/23
- [Qemu-devel] [PULL 24/61] qcow2: Use offset_into_cluster() and offset_to_l2_index(), Kevin Wolf, 2017/06/23
- [Qemu-devel] [PULL 25/61] qed: Use bottom half to resume waiting requests, Kevin Wolf, 2017/06/23
- [Qemu-devel] [PULL 26/61] qed: Make qed_read_table() synchronous, Kevin Wolf, 2017/06/23
- [Qemu-devel] [PULL 28/61] qed: Remove callback from qed_read_l2_table(), Kevin Wolf, 2017/06/23
- [Qemu-devel] [PULL 29/61] qed: Remove callback from qed_find_cluster(), Kevin Wolf, 2017/06/23