Skip to content

block: Make raw_co_get_allocated_file_size asynchronous

Fabiano Rosas qemu-devel 3 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v1 posting 2/22 patches 1 replyApplied
  2. v2 Latest10 patches 13 repliesIn review
  3. v1 RFC posting 1/26 patches 16 repliesSuperseded

changes from the cover letter

- fixed duplicated commit message [Lin]
- clarified why we need to convert info-block [Claudio]
- added my rationale of why the changes are safe [Eric]
- converted all callers to coroutines [Kevin]
- made hmp_nbd_server_start don't depend on qmp_query_block

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/10block: Remove bdrv_query_block_node_infoblock/qapi.c include/block/qapi.h+0 -300 replies
2/10block: Remove unnecessary variable in bdrv_block_device_infoblock/qapi.c+2 -31 reply
3/10block: Allow the wrapper script to see functions declared in qapi.hblock/meson.build scripts/block-coroutine-wrapper.py+2 -01 reply
4/10block: Temporarily mark bdrv_co_get_allocated_file_size as mixedinclude/block/block-io.h+1 -11 reply
5/10block: Convert bdrv_query_block_graph_info to coroutineblock/qapi.c include/block/qapi.h qemu-img.c+12 -81 reply
6/10block: Convert bdrv_block_device_info into co_wrapperblock/qapi.c include/block/qapi.h+12 -81 reply
7/10block: Convert qmp_query_named_block_nodes to coroutineblock.c blockdev.c qapi/block-core.json+6 -51 reply
8/10block: Don't query all block devices at hmp_nbd_server_startblock/monitor/block-hmp-cmds.c+12 -81 reply
9/10block: Convert qmp_query_block() to coroutine_fnblock.c block/monitor/block-hmp-cmds.c block/qapi.c +5 more+19 -223 replies
10/10block: Add a thread-pool version of fstatblock/file-posix.c include/block/raw-aio.h+40 -41 reply

Reviews trailers per patch

6 of 10 patches have a Reviewed-by or Acked-by.

PatchEric BlakeClaudio FontanaPhilippe Mathieu-DaudéHanna Czenczek
1/10R-b
2/10R-b
3/10R-b
4/10R-b R-b
5/10R-b
6/10
7/10
8/10
9/10
10/10R-b R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 4 reviewers.

Read the v2 thread

Cover letter [PATCH v2 00/10] block: Make raw_co_get_allocated_file_size asynchronous

Hi,

The major change from the last version is that this time I'm moving all of the callers of bdrv_get_allocated_file_size() into coroutines. I had to make some temporary changes to avoid asserts while not all the callers were converted.

I tried my best to explain why I think the changes are safe. To avoid changing too much of the code I added a change that removes the dependency of qmp_query_block from hmp_nbd_server_start, that way I don't need to move all of the nbd code into a coroutine as well.

Based on:
[PATCH v2 00/11] block: Re-enable the graph lock
https://lore.kernel.org/r/[email protected]

changes:

- fixed duplicated commit message [Lin]
- clarified why we need to convert info-block [Claudio]
- added my rationale of why the changes are safe [Eric]
- converted all callers to coroutines [Kevin]
- made hmp_nbd_server_start don't depend on qmp_query_block

CI run: https://gitlab.com/farosas/qemu/-/pipelines/895525156
===
v1:
https://lore.kernel.org/r/[email protected]

As discussed in another thread [1], here's an RFC addressing a VCPU softlockup encountered when issuing QMP commands that target a disk placed on NFS.

Since QMP commands happen with the qemu_global_mutex locked, any command that takes too long to finish will block other threads waiting to take the global mutex. One such thread could be a VCPU thread going out of the guest to handle IO.

This is the case when issuing the QMP command query-block, which eventually calls raw_co_get_allocated_file_size(). This function makes an 'fstat' call that has been observed to take a long time (seconds) over NFS.

NFS latency issues aside, we can improve the situation by not blocking VCPU threads while the command is running.

Move the 'fstat' call into the thread-pool and make the necessary adaptations to ensure raw_co_get_allocated_file_size runs in a coroutine in the block driver aio_context.

1- Question about QMP and BQL
https://lists.gnu.org/archive/html/qemu-devel/2023-05/msg03141.html

Fabiano Rosas (8):
block: Remove bdrv_query_block_node_info
block: Remove unnecessary variable in bdrv_block_device_info
block: Allow the wrapper script to see functions declared in qapi.h
block: Temporarily mark bdrv_co_get_allocated_file_size as mixed
block: Convert bdrv_query_block_graph_info to coroutine
block: Convert bdrv_block_device_info into co_wrapper
block: Don't query all block devices at hmp_nbd_server_start
block: Convert qmp_query_block() to coroutine_fn

João Silva (1):
block: Add a thread-pool version of fstat

Lin Ma (1):
block: Convert qmp_query_named_block_nodes to coroutine

 block/file-posix.c                 | 40 +++++++++++++++++--
 block/meson.build                  |  1 +
 block/monitor/block-hmp-cmds.c     | 22 ++++++-----
 block/qapi.c                       | 62 +++++++++---------------------
 blockdev.c                         |  6 +--
 hmp-commands-info.hx               |  1 +
 include/block/block-hmp-cmds.h     |  2 +-
 include/block/qapi.h               | 17 ++++----
 include/block/raw-aio.h            |  4 +-
 qapi/block-core.json               |  5 ++-
 qemu-img.c                         |  2 -
 scripts/block-coroutine-wrapper.py |  1 +
 12 files changed, 90 insertions(+), 73 deletions(-)
Signature · 1 line
2.35.3