@@ -2306,9 +2306,7 @@ static coroutine_fn int qcow2_co_preadv_task(BlockDriverState *bs,
}
if (req) {
- WITH_QEMU_LOCK_GUARD(&s->lock) {
- reqlist_free_req(req);
- }
+ reqlist_mark_req_invalid(req);
}
return ret;
@@ -2348,6 +2346,7 @@ static coroutine_fn int qcow2_co_preadv_part(BlockDriverState *bs,
}
qemu_co_mutex_lock(&s->lock);
+ reqlist_free_invalid_reqs(&s->guest_reqs);
ret = qcow2_get_host_offset(bs, offset, &cur_bytes,
&host_offset, &type, &req);
qemu_co_mutex_unlock(&s->lock);
@@ -2769,6 +2768,8 @@ static void qcow2_close(BlockDriverState *bs)
qcow2_refcount_close(bs);
qcow2_free_snapshots(bs);
+
+ reqlist_free_invalid_reqs(&s->guest_reqs);
}
static void coroutine_fn qcow2_co_invalidate_cache(BlockDriverState *bs,
@@ -4619,6 +4620,7 @@ qcow2_co_pwritev_compressed_task(BlockDriverState *bs,
}
qemu_co_mutex_lock(&s->lock);
+ reqlist_free_invalid_reqs(&s->guest_reqs);
ret = qcow2_alloc_compressed_cluster_offset(bs, offset, out_len,
&cluster_offset, &req);
if (ret < 0) {
@@ -4641,9 +4643,7 @@ success:
ret = 0;
fail:
if (req) {
- WITH_QEMU_LOCK_GUARD(&s->lock) {
- reqlist_free_req(req);
- }
+ reqlist_mark_req_invalid(req);
}
qemu_vfree(buf);
g_free(out_buf);
Instead of small critical sections which wants only to remove a request from the list let's use new atomic interface. And don't forget to call reqlist_free_invalid_reqs() when we are in a critical section anyway, to not overflow the RAM with invalid requests. Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> --- block/qcow2.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)