qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v7 11/11] qcow2: use reqlist_mark_req_invalid()


From: Vladimir Sementsov-Ogievskiy
Subject: [PATCH v7 11/11] qcow2: use reqlist_mark_req_invalid()
Date: Sat, 4 Sep 2021 19:24:28 +0300

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(-)

diff --git a/block/qcow2.c b/block/qcow2.c
index aefe6558b6..f2094c1ecc 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -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);
-- 
2.29.2




reply via email to

[Prev in Thread] Current Thread [Next in Thread]