Skip to content

blkdebug: fix racing condition when iterating on

Emanuele Giuseppe Esposito qemu-devel 5 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v5 Latest6 patches 5 repliesIn review
  2. v46 patches 9 repliesSuperseded
  3. v35 patches 7 repliesSuperseded
Earlier versions · 2
VersionPostedPatchesRepliesStatus
v25 patches5 repliesSuperseded
v15 patches2 repliesSuperseded

Changes in v5 from the cover letter

* 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

Patches in v5 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/6blkdebug: refactor removal of a suspended requestblock/blkdebug.c+22 -110 replies
2/6blkdebug: move post-resume handling to resume_req_by_tagblock/blkdebug.c+18 -131 reply
3/6blkdebug: track all actionsblock/blkdebug.c+8 -91 reply
4/6blkdebug: do not suspend in the middle of QLIST_FOREACH_SAFEblock/blkdebug.c+6 -10 replies
5/6block/blkdebug: remove new_state field and instead use a local variableblock/blkdebug.c+6 -71 reply
6/6blkdebug: protect rules and suspended_reqs with a lockblock/blkdebug.c+39 -101 reply

Reviews trailers per patch

All 6 patches have a Reviewed-by or Acked-by.

PatchVladimir Sementsov-OgievskiyEric Blake
1/6R-b R-b
2/6R-b
3/6R-b
4/6R-b
5/6R-b
6/6R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v5 thread

Cover letter [PATCH v5 0/6] blkdebug: fix racing condition when iterating on

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.

---
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(-)
Signature · 1 line
2.31.1