Skip to content

Protect the block layer with a rwlock: part 3

Emanuele Giuseppe Esposito qemu-devel 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest15 patches 8 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/15block/qed: add missing graph rdlock in qed_need_check_timer_entryblock/qed.c+3 -00 replies
2/15block: rename refresh_total_sectors in bdrv_refresh_total_sectorsblock.c block/io.c include/block/block_int-io.h+10 -80 replies
3/15block-backend: use bdrv_getlength instead of blk_getlengthblock/block-backend.c+1 -10 replies
4/15block: convert bdrv_refresh_total_sectors in generated_co_wrapperblock.c block/block-backend.c block/commit.c +8 more+72 -190 replies
5/15block: use bdrv_co_refresh_total_sectors when possibleblock/block-backend.c block/copy-on-read.c block/io.c+6 -60 replies
6/15block: convert bdrv_get_allocated_file_size in generated_co_wrapper_simpleblock.c block/qcow2-refcount.c include/block/block-io.h +1 more+11 -60 replies
7/15block: convert bdrv_get_info in generated_co_wrapperblock.c block/crypto.c block/io.c +5 more+28 -140 replies
8/15block: convert bdrv_is_inserted in generated_co_wrapper_simpleblock.c block/block-backend.c block/io.c +4 more+29 -150 replies
9/15block-coroutine-wrapper: support void functionsscripts/block-coroutine-wrapper.py+14 -50 replies
10/15block: convert bdrv_eject in generated_co_wrapper_simpleblock.c block/block-backend.c block/copy-on-read.c +5 more+14 -90 replies
11/15block: convert bdrv_lock_medium in generated_co_wrapper_simpleblock.c block/block-backend.c block/copy-on-read.c +5 more+14 -90 replies
12/15block: convert bdrv_debug_event in generated_co_wrapperblock.c block/io.c include/block/block-io.h +1 more+22 -150 replies
13/15block: convert bdrv_io_plug in generated_co_wrapper_simpleblock/block-backend.c block/io.c include/block/block-io.h +2 more+13 -80 replies
14/15block: convert bdrv_io_unplug in generated_co_wrapper_simpleblock/block-backend.c block/io.c include/block/block-io.h +2 more+11 -80 replies
15/15block: rename newly converted BlockDriver IO coroutine functionsblock.c block/blkdebug.c block/blkio.c +31 more+131 -1300 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 00/15] Protect the block layer with a rwlock: part 3

Please read "Protect the block layer with a rwlock: part 1" and "Protect the block layer with a rwlock: part 2" for an additional introduction and aim of this series.

In this serie, we cover the remaining BlockDriver IO callbacks that were not running in coroutine, therefore not using the graph rdlock. Therefore convert them to coroutines, using either g_c_w or a new variant introduced in this serie (see below).

We need to convert these callbacks into coroutine because non-coroutine code is tied to the main thread, even though it will still delegate I/O accesses to the iothread (via the bdrv_coroutine_enter call in generated_co_wrappers). Making callbacks run in coroutines provides more flexibility, because they run entirely in iothreads and can use CoMutexes for mutual exclusion.

Here we introduce generated_co_wrapper_simple, a simplification of g_c_w that only considers the case where the caller is not in a coroutine. This simplifies and clarifies a lot when the caller is a coroutine or not, and in the future will hopefully replace g_c_w.

While we are at it, try to directly call the _co_ counterpart of a g_c_w when we know already that the function always run in a coroutine.

Based-on: <[email protected]>

Thank you,
Emanuele

Emanuele Giuseppe Esposito (15):
block/qed: add missing graph rdlock in qed_need_check_timer_entry
block: rename refresh_total_sectors in bdrv_refresh_total_sectors
block-backend: use bdrv_getlength instead of blk_getlength
block: convert bdrv_refresh_total_sectors in generated_co_wrapper
block: use bdrv_co_refresh_total_sectors when possible
block: convert bdrv_get_allocated_file_size in
generated_co_wrapper_simple
block: convert bdrv_get_info in generated_co_wrapper
block: convert bdrv_is_inserted in generated_co_wrapper_simple
block-coroutine-wrapper: support void functions
block: convert bdrv_eject in generated_co_wrapper_simple
block: convert bdrv_lock_medium in generated_co_wrapper_simple
block: convert bdrv_debug_event in generated_co_wrapper
block: convert bdrv_io_plug in generated_co_wrapper_simple
block: convert bdrv_io_unplug in generated_co_wrapper_simple
block: rename newly converted BlockDriver IO coroutine functions

 block.c                            | 93 +++++++++++++++++++-----------
 block/blkdebug.c                   |  4 +-
 block/blkio.c                      |  6 +-
 block/blklogwrites.c               |  2 +-
 block/blkreplay.c                  |  2 +-
 block/blkverify.c                  |  2 +-
 block/block-backend.c              | 43 ++++++++------
 block/commit.c                     |  4 +-
 block/copy-on-read.c               | 12 ++--
 block/crypto.c                     |  6 +-
 block/curl.c                       |  8 +--
 block/file-posix.c                 | 48 +++++++--------
 block/file-win32.c                 |  8 +--
 block/filter-compress.c            | 10 ++--
 block/gluster.c                    | 16 ++---
 block/io.c                         | 78 +++++++++++++------------
 block/iscsi.c                      |  8 +--
 block/meson.build                  |  1 +
 block/mirror.c                     | 17 ++++--
 block/nbd.c                        |  6 +-
 block/nfs.c                        |  2 +-
 block/null.c                       |  8 +--
 block/nvme.c                       |  6 +-
 block/preallocate.c                |  2 +-
 block/qcow.c                       |  2 +-
 block/qcow2-refcount.c             |  2 +-
 block/qcow2.c                      |  6 +-
 block/qed.c                        |  7 ++-
 block/quorum.c                     |  2 +-
 block/raw-format.c                 | 14 ++---
 block/rbd.c                        |  4 +-
 block/replication.c                |  2 +-
 block/ssh.c                        |  2 +-
 block/stream.c                     |  4 +-
 block/throttle.c                   |  2 +-
 block/vdi.c                        |  2 +-
 block/vhdx.c                       |  2 +-
 block/vmdk.c                       |  4 +-
 block/vpc.c                        |  2 +-
 blockdev.c                         |  8 ++-
 hw/scsi/scsi-disk.c                |  5 ++
 include/block/block-io.h           | 40 +++++++++----
 include/block/block_int-common.h   | 37 +++++++-----
 include/block/block_int-io.h       |  5 +-
 include/sysemu/block-backend-io.h  | 32 +++++++---
 scripts/block-coroutine-wrapper.py | 19 ++++--
 tests/unit/test-block-iothread.c   |  7 +++
 47 files changed, 364 insertions(+), 238 deletions(-)
Signature · 1 line
2.31.1