[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 22/79] qemu-img: wait for convert coroutines to comp
From: |
Michael Roth |
Subject: |
[Qemu-devel] [PATCH 22/79] qemu-img: wait for convert coroutines to complete |
Date: |
Mon, 28 Aug 2017 19:13:57 -0500 |
From: Anton Nefedov <address@hidden>
On error path (like i/o error in one of the coroutines), it's required to
- wait for coroutines completion before cleaning the common structures
- reenter dependent coroutines so they ever finish
Introduced in 2d9187bc65.
Cc: address@hidden
Signed-off-by: Anton Nefedov <address@hidden>
Reviewed-by: Peter Lieven <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
(cherry picked from commit b91127edd0ff96f27f1e58e47f4e9f9d6a0fed02)
Signed-off-by: Michael Roth <address@hidden>
---
qemu-img.c | 26 +++++++++++---------------
1 file changed, 11 insertions(+), 15 deletions(-)
diff --git a/qemu-img.c b/qemu-img.c
index 2e61561..26ded22 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -1761,13 +1761,13 @@ static void coroutine_fn convert_co_do_copy(void
*opaque)
qemu_co_mutex_lock(&s->lock);
if (s->ret != -EINPROGRESS || s->sector_num >= s->total_sectors) {
qemu_co_mutex_unlock(&s->lock);
- goto out;
+ break;
}
n = convert_iteration_sectors(s, s->sector_num);
if (n < 0) {
qemu_co_mutex_unlock(&s->lock);
s->ret = n;
- goto out;
+ break;
}
/* save current sector and allocation status to local variables */
sector_num = s->sector_num;
@@ -1792,7 +1792,6 @@ static void coroutine_fn convert_co_do_copy(void *opaque)
error_report("error while reading sector %" PRId64
": %s", sector_num, strerror(-ret));
s->ret = ret;
- goto out;
}
} else if (!s->min_sparse && status == BLK_ZERO) {
status = BLK_DATA;
@@ -1801,22 +1800,20 @@ static void coroutine_fn convert_co_do_copy(void
*opaque)
if (s->wr_in_order) {
/* keep writes in order */
- while (s->wr_offs != sector_num) {
- if (s->ret != -EINPROGRESS) {
- goto out;
- }
+ while (s->wr_offs != sector_num && s->ret == -EINPROGRESS) {
s->wait_sector_num[index] = sector_num;
qemu_coroutine_yield();
}
s->wait_sector_num[index] = -1;
}
- ret = convert_co_write(s, sector_num, n, buf, status);
- if (ret < 0) {
- error_report("error while writing sector %" PRId64
- ": %s", sector_num, strerror(-ret));
- s->ret = ret;
- goto out;
+ if (s->ret == -EINPROGRESS) {
+ ret = convert_co_write(s, sector_num, n, buf, status);
+ if (ret < 0) {
+ error_report("error while writing sector %" PRId64
+ ": %s", sector_num, strerror(-ret));
+ s->ret = ret;
+ }
}
if (s->wr_in_order) {
@@ -1837,7 +1834,6 @@ static void coroutine_fn convert_co_do_copy(void *opaque)
}
}
-out:
qemu_vfree(buf);
s->co[index] = NULL;
s->running_coroutines--;
@@ -1899,7 +1895,7 @@ static int convert_do_copy(ImgConvertState *s)
qemu_coroutine_enter(s->co[i]);
}
- while (s->ret == -EINPROGRESS) {
+ while (s->running_coroutines) {
main_loop_wait(false);
}
--
2.7.4
- [Qemu-devel] [PATCH 13/79] 9pfs: local: fix unlink of alien files in mapped-file mode, (continued)
- [Qemu-devel] [PATCH 13/79] 9pfs: local: fix unlink of alien files in mapped-file mode, Michael Roth, 2017/08/28
- [Qemu-devel] [PATCH 11/79] ACPI: don't call acpi_pcihp_device_plug_cb on xen, Michael Roth, 2017/08/28
- [Qemu-devel] [PATCH 16/79] qobject: Add helper macros for common scalar insertions, Michael Roth, 2017/08/28
- [Qemu-devel] [PATCH 12/79] replication: Make --disable-replication compile again, Michael Roth, 2017/08/28
- [Qemu-devel] [PATCH 17/79] s390x: Drop useless casts, Michael Roth, 2017/08/28
- [Qemu-devel] [PATCH 21/79] aio: add missing aio_notify() to aio_enable_external(), Michael Roth, 2017/08/28
- [Qemu-devel] [PATCH 15/79] qobject: Drop useless QObject casts, Michael Roth, 2017/08/28
- [Qemu-devel] [PATCH 01/79] qga-win: Enable 'can-offline' field in 'guest-get-vcpus' reply, Michael Roth, 2017/08/28
- [Qemu-devel] [PATCH 19/79] block: Reuse bs as backing hd for drive-backup sync=none, Michael Roth, 2017/08/28
- [Qemu-devel] [PATCH 20/79] hw/virtio: fix vhost user fails to startup when MQ, Michael Roth, 2017/08/28
- [Qemu-devel] [PATCH 22/79] qemu-img: wait for convert coroutines to complete,
Michael Roth <=
- [Qemu-devel] [PATCH 23/79] block/vhdx: Make vhdx_create() always set errp, Michael Roth, 2017/08/28
- [Qemu-devel] [PATCH 27/79] target/xtensa: fix return value of read/write simcalls, Michael Roth, 2017/08/28
- [Qemu-devel] [PATCH 26/79] target/xtensa: fix mapping direction in read/write simcalls, Michael Roth, 2017/08/28
- [Qemu-devel] [PATCH 29/79] curl: never invoke callbacks with s->mutex held, Michael Roth, 2017/08/28
- [Qemu-devel] [PATCH 18/79] qobject: Use simpler QDict/QList scalar insertion macros, Michael Roth, 2017/08/28
- [Qemu-devel] [PATCH 25/79] blockdev: use drained_begin/end for qmp_block_resize, Michael Roth, 2017/08/28
- [Qemu-devel] [PATCH 24/79] block: Add errp to b{lk, drv}_truncate(), Michael Roth, 2017/08/28
- [Qemu-devel] [PATCH 34/79] virtio-scsi: Unset hotplug handler when unrealize, Michael Roth, 2017/08/28
- [Qemu-devel] [PATCH 02/79] dirty-bitmap: Report BlockDirtyInfo.count in bytes, as documented, Michael Roth, 2017/08/28
- [Qemu-devel] [PATCH 28/79] curl: strengthen assertion in curl_clean_state, Michael Roth, 2017/08/28