Skip to content

block: Move more functions to coroutines

Kevin Wolf qemu-devel 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest14 patches 1 replyIn review
  2. v114 patches 13 repliesSuperseded

Changes in v2 from the cover letter

- In each patch converting a BlockDriver callback to be called in coroutine, also immediately rename it and its implementation to include co_ in its name, as well as mark the implementations coroutine_fn [Vladimir]
- Moved bdrv_is_inserted() earlier in the series because raw_is_inserted() calls raw_getlength(), so it needs to be converted first to avoid calling a coroutine_fn from a non-coroutine_fn in an intermediate state.
- The final patch only renames bdrv_load/save_vmstate() any more, which was already converted to coroutine_fn earlier.
- Since pretty much every patch was touched in this, I refrained from picking up any Reviewed-by for v1

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/14block-coroutine-wrapper: support void functionsscripts/block-coroutine-wrapper.py+15 -50 replies
2/14block: Convert bdrv_io_plug() to co_wrapperblock/block-backend.c block/file-posix.c block/io.c +4 more+19 -160 replies
3/14block: Convert bdrv_io_unplug() to co_wrapperblock/blkio.c block/block-backend.c block/file-posix.c +5 more+20 -190 replies
4/14block: Convert bdrv_is_inserted() to co_wrapperblock.c block/block-backend.c block/file-posix.c +5 more+32 -200 replies
5/14block: Rename refresh_total_sectors to bdrv_refresh_total_sectorsblock.c block/io.c include/block/block_int-io.h+10 -80 replies
6/14block: Convert bdrv_refresh_total_sectors() to co_wrapper_mixedblock.c block/blkdebug.c block/blkio.c +32 more+161 -1210 replies
7/14block-backend: use bdrv_getlength instead of blk_getlengthblock/block-backend.c+1 -10 replies
8/14block: use bdrv_co_refresh_total_sectors when possibleblock/block-backend.c block/io.c block/preallocate.c +1 more+9 -90 replies
9/14block: Convert bdrv_get_allocated_file_size() to co_wrapperblock.c block/file-posix.c block/file-win32.c +7 more+39 -380 replies
10/14block: Convert bdrv_get_info() to co_wrapper_mixedblock.c block/blkio.c block/crypto.c +15 more+59 -430 replies
11/14block: Convert bdrv_eject() to co_wrapperblock.c block/block-backend.c block/copy-on-read.c +6 more+25 -210 replies
12/14block: Convert bdrv_lock_medium() to co_wrapperblock.c block/block-backend.c block/copy-on-read.c +6 more+24 -210 replies
13/14block: Convert bdrv_debug_event() to co_wrapper_mixedblock.c block/blkdebug.c block/io.c +2 more+23 -180 replies
14/14block: Rename bdrv_load/save_vmstate() to bdrv_co_load/save_vmstate()block/io.c block/qcow2.c include/block/block_int-common.h+12 -120 replies

Reviews trailers per patch

None of the 14 patches has a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchEmanuele Giuseppe Esposito
SeriesR-b
1/14
2/14
3/14
4/14
5/14
6/14
7/14
8/14
9/14
10/14
11/14
12/14
13/14
14/14

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

Read the v2 thread

Cover letter [PATCH v2 00/14] block: Move more functions to coroutines

This series converts some IO_CODE() functions to coroutine_fn because they access the graph and will need to hold the graph lock in the future. IO_CODE() functions can be called from iothreads, so taking the graph lock requires the function to run in coroutine context.

Pretty much all of the changes in this series were posted by Emanuele before as part of "Protect the block layer with a rwlock: part 3". The major difference is that in the old version, the patches did two things at once: Converting functions to coroutine_fn, and adding the locking to them. This series does only the coroutine conversion. The locking part will be in another series which now comes with TSA annotations and makes the locking related changes big enough to have separate patches.

v2:
- In each patch converting a BlockDriver callback to be called in coroutine, also immediately rename it and its implementation to include co_ in its name, as well as mark the implementations coroutine_fn [Vladimir]
- Moved bdrv_is_inserted() earlier in the series because raw_is_inserted() calls raw_getlength(), so it needs to be converted first to avoid calling a coroutine_fn from a non-coroutine_fn in an intermediate state.
- The final patch only renames bdrv_load/save_vmstate() any more, which was already converted to coroutine_fn earlier.
- Since pretty much every patch was touched in this, I refrained from picking up any Reviewed-by for v1

Emanuele Giuseppe Esposito (14):
block-coroutine-wrapper: support void functions
block: Convert bdrv_io_plug() to co_wrapper
block: Convert bdrv_io_unplug() to co_wrapper
block: Convert bdrv_is_inserted() to co_wrapper
block: Rename refresh_total_sectors to bdrv_refresh_total_sectors
block: Convert bdrv_refresh_total_sectors() to co_wrapper_mixed
block-backend: use bdrv_getlength instead of blk_getlength
block: use bdrv_co_refresh_total_sectors when possible
block: Convert bdrv_get_allocated_file_size() to co_wrapper
block: Convert bdrv_get_info() to co_wrapper_mixed
block: Convert bdrv_eject() to co_wrapper
block: Convert bdrv_lock_medium() to co_wrapper
block: Convert bdrv_debug_event() to co_wrapper_mixed
block: Rename bdrv_load/save_vmstate() to bdrv_co_load/save_vmstate()

 include/block/block-io.h           |  36 +++++++---
 include/block/block_int-common.h   |  26 ++++---
 include/block/block_int-io.h       |   5 +-
 include/sysemu/block-backend-io.h  |  31 +++++++--
 block.c                            |  82 +++++++++++++---------
 block/blkdebug.c                   |  11 +--
 block/blkio.c                      |  15 ++--
 block/blklogwrites.c               |   6 +-
 block/blkreplay.c                  |   6 +-
 block/blkverify.c                  |   6 +-
 block/block-backend.c              |  36 +++++-----
 block/commit.c                     |   4 +-
 block/copy-on-read.c               |  18 ++---
 block/crypto.c                     |  14 ++--
 block/curl.c                       |  10 +--
 block/file-posix.c                 | 107 ++++++++++++++---------------
 block/file-win32.c                 |  18 +++--
 block/filter-compress.c            |  20 +++---
 block/gluster.c                    |  23 ++++---
 block/io.c                         |  76 ++++++++++----------
 block/iscsi.c                      |  17 ++---
 block/mirror.c                     |   6 +-
 block/nbd.c                        |   8 +--
 block/nfs.c                        |   4 +-
 block/null.c                       |  13 ++--
 block/nvme.c                       |  14 ++--
 block/preallocate.c                |  16 ++---
 block/qcow.c                       |   5 +-
 block/qcow2-refcount.c             |   2 +-
 block/qcow2.c                      |  17 ++---
 block/qed.c                        |  11 +--
 block/quorum.c                     |   8 +--
 block/raw-format.c                 |  25 +++----
 block/rbd.c                        |   9 +--
 block/replication.c                |   6 +-
 block/ssh.c                        |   4 +-
 block/throttle.c                   |   6 +-
 block/vdi.c                        |   7 +-
 block/vhdx.c                       |   5 +-
 block/vmdk.c                       |  14 ++--
 block/vpc.c                        |   5 +-
 blockdev.c                         |   8 ++-
 hw/scsi/scsi-disk.c                |   5 ++
 tests/unit/test-block-iothread.c   |   3 +
 scripts/block-coroutine-wrapper.py |  20 ++++--
 block/meson.build                  |   1 +
 46 files changed, 443 insertions(+), 346 deletions(-)
Signature · 1 line
2.38.1