From: Emanuele Giuseppe Esposito <eesposit@redhat.com>
To: qemu-block@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
Emanuele Giuseppe Esposito <eesposit@redhat.com>,
Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>,
qemu-devel@nongnu.org, Max Reitz <mreitz@redhat.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Eric Blake <eblake@redhat.com>
Subject: [PATCH v5 0/6] blkdebug: fix racing condition when iterating on
Date: Mon, 14 Jun 2021 10:29:25 +0200 [thread overview]
Message-ID: <20210614082931.24925-1-eesposit@redhat.com> (raw)
When qemu_coroutine_enter is executed in a loop
(even QEMU_FOREACH_SAFE), the new routine can modify the list,
for example removing an element, causing problem when control
is given back to the caller that continues iterating on the same list.
Patch 1 solves the issue in blkdebug_debug_resume by restarting
the list walk after every coroutine_enter if list has to be fully iterated.
Patches 2,3,4 aim to fix blkdebug_debug_event by gathering
all actions that the rules make in a counter and invoking
the respective coroutine_yeld only after processing all requests.
Patch 5-6 are somewhat independent of the others, patch 5 removes the need
of new_state field, and patch 6 adds a lock to
protect rules and suspended_reqs; right now everything works because
it's protected by the AioContext lock.
This is a preparation for the current proposal of removing the AioContext
lock and instead using smaller granularity locks to allow multiple
iothread execution in the same block device.
Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
---
v5:
* Add comment in patch 1 to explain why we don't need _SAFE in for loop
* Move the state update (s->state = new_state) in patch 5, to maintain
the same existing effect in all patches
Emanuele Giuseppe Esposito (6):
blkdebug: refactor removal of a suspended request
blkdebug: move post-resume handling to resume_req_by_tag
blkdebug: track all actions
blkdebug: do not suspend in the middle of QLIST_FOREACH_SAFE
block/blkdebug: remove new_state field and instead use a local
variable
blkdebug: protect rules and suspended_reqs with a lock
block/blkdebug.c | 136 ++++++++++++++++++++++++++++++++---------------
1 file changed, 92 insertions(+), 44 deletions(-)
--
2.31.1
next reply other threads:[~2021-06-14 8:31 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-14 8:29 Emanuele Giuseppe Esposito [this message]
2021-06-14 8:29 ` [PATCH v5 1/6] blkdebug: refactor removal of a suspended request Emanuele Giuseppe Esposito
2021-06-14 8:29 ` [PATCH v5 2/6] blkdebug: move post-resume handling to resume_req_by_tag Emanuele Giuseppe Esposito
2021-07-15 9:59 ` Max Reitz
2021-06-14 8:29 ` [PATCH v5 3/6] blkdebug: track all actions Emanuele Giuseppe Esposito
2021-07-15 9:59 ` Max Reitz
2021-06-14 8:29 ` [PATCH v5 4/6] blkdebug: do not suspend in the middle of QLIST_FOREACH_SAFE Emanuele Giuseppe Esposito
2021-06-14 8:29 ` [PATCH v5 5/6] block/blkdebug: remove new_state field and instead use a local variable Emanuele Giuseppe Esposito
2021-06-19 12:38 ` Vladimir Sementsov-Ogievskiy
2021-06-14 8:29 ` [PATCH v5 6/6] blkdebug: protect rules and suspended_reqs with a lock Emanuele Giuseppe Esposito
2021-06-19 12:42 ` Vladimir Sementsov-Ogievskiy
2021-07-15 10:06 ` [PATCH v5 0/6] blkdebug: fix racing condition when iterating on Max Reitz
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=20210614082931.24925-1-eesposit@redhat.com \
--to=eesposit@redhat.com \
--cc=eblake@redhat.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=vsementsov@virtuozzo.com \
/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).