From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
To: qemu-block@nongnu.org
Cc: qemu-devel@nongnu.org, vsementsov@virtuozzo.com,
hreitz@redhat.com, kwolf@redhat.com
Subject: [PATCH v7 11/11] qcow2: use reqlist_mark_req_invalid()
Date: Sat, 4 Sep 2021 19:24:28 +0300 [thread overview]
Message-ID: <20210904162428.222008-12-vsementsov@virtuozzo.com> (raw)
In-Reply-To: <20210904162428.222008-1-vsementsov@virtuozzo.com>
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
next prev parent reply other threads:[~2021-09-04 16:40 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-04 16:24 [PATCH v7 00/11] qcow2: fix parallel rewrite and discard (reqlist) Vladimir Sementsov-Ogievskiy
2021-09-04 16:24 ` [PATCH v7 01/11] block/reqlist: drop extra assertion Vladimir Sementsov-Ogievskiy
2021-09-04 16:24 ` [PATCH v7 02/11] block/reqlist: add reqlist_new_req() and reqlist_free_req() Vladimir Sementsov-Ogievskiy
2021-09-04 16:24 ` [PATCH v7 03/11] iotests: add qcow2-discard-during-rewrite Vladimir Sementsov-Ogievskiy
2021-09-04 16:24 ` [PATCH v7 04/11] qcow2: introduce qcow2_parse_compressed_cluster_descriptor() Vladimir Sementsov-Ogievskiy
2021-09-04 16:24 ` [PATCH v7 05/11] qcow2: refactor qcow2_co_preadv_task() to have one return Vladimir Sementsov-Ogievskiy
2021-09-04 16:24 ` [PATCH v7 06/11] qcow2: prepare for tracking guest io requests in data_file Vladimir Sementsov-Ogievskiy
2021-09-04 16:24 ` [PATCH v7 07/11] qcow2: track " Vladimir Sementsov-Ogievskiy
2021-09-04 16:24 ` [PATCH v7 08/11] qcow2: introduce is_cluster_free() helper Vladimir Sementsov-Ogievskiy
2021-09-04 16:24 ` [PATCH v7 09/11] qcow2: don't reallocate host clusters under guest operation Vladimir Sementsov-Ogievskiy
2021-09-04 16:24 ` [PATCH v7 10/11] block/reqlist: implement reqlist_mark_req_invalid() Vladimir Sementsov-Ogievskiy
2021-09-04 16:24 ` Vladimir Sementsov-Ogievskiy [this message]
2021-09-22 8:24 ` [PATCH v7 00/11] qcow2: fix parallel rewrite and discard (reqlist) Vladimir Sementsov-Ogievskiy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210904162428.222008-12-vsementsov@virtuozzo.com \
--to=vsementsov@virtuozzo.com \
--cc=hreitz@redhat.com \
--cc=kwolf@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).