aboutsummaryrefslogtreecommitdiff
path: root/block/qcow2.c
diff options
context:
space:
mode:
Diffstat (limited to 'block/qcow2.c')
-rw-r--r--block/qcow2.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/block/qcow2.c b/block/qcow2.c
index b725d68b1d..8aed31004d 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -526,13 +526,14 @@ static int qcow2_co_writev(BlockDriverState *bs,
int n_end;
int ret;
int cur_nr_sectors; /* number of sectors in current iteration */
- QCowL2Meta l2meta;
uint64_t cluster_offset;
QEMUIOVector hd_qiov;
uint64_t bytes_done = 0;
uint8_t *cluster_data = NULL;
+ QCowL2Meta l2meta = {
+ .nb_clusters = 0,
+ };
- l2meta.nb_clusters = 0;
qemu_co_queue_init(&l2meta.dependent_requests);
qemu_iovec_init(&hd_qiov, qiov->niov);
@@ -592,13 +593,12 @@ static int qcow2_co_writev(BlockDriverState *bs,
}
ret = qcow2_alloc_cluster_link_l2(bs, &l2meta);
-
- run_dependent_requests(s, &l2meta);
-
if (ret < 0) {
goto fail;
}
+ run_dependent_requests(s, &l2meta);
+
remaining_sectors -= cur_nr_sectors;
sector_num += cur_nr_sectors;
bytes_done += cur_nr_sectors * 512;
@@ -606,6 +606,8 @@ static int qcow2_co_writev(BlockDriverState *bs,
ret = 0;
fail:
+ run_dependent_requests(s, &l2meta);
+
qemu_co_mutex_unlock(&s->lock);
qemu_iovec_destroy(&hd_qiov);