qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/15] Protect the block layer with a rwlock: part 3
@ 2022-11-16 14:07 Emanuele Giuseppe Esposito
  2022-11-16 14:07 ` [PATCH 01/15] block/qed: add missing graph rdlock in qed_need_check_timer_entry Emanuele Giuseppe Esposito
                   ` (16 more replies)
  0 siblings, 17 replies; 24+ messages in thread
From: Emanuele Giuseppe Esposito @ 2022-11-16 14:07 UTC (permalink / raw)
  To: qemu-block
  Cc: Kevin Wolf, Hanna Reitz, Stefan Hajnoczi, Ari Sundholm,
	Pavel Dovgalyuk, Paolo Bonzini, John Snow,
	Vladimir Sementsov-Ogievskiy, Stefan Weil, Fam Zheng,
	Ronnie Sahlberg, Peter Lieven, Eric Blake,
	Philippe Mathieu-Daudé, Alberto Garcia, Ilya Dryomov,
	Wen Congyang, Xie Changlong, Richard W.M. Jones, Jeff Cody,
	Cleber Rosa, qemu-devel, integration, Emanuele Giuseppe Esposito

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: <20221116135331.3052923-1-eesposit@redhat.com>

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(-)

-- 
2.31.1



^ permalink raw reply	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2022-11-23 18:13 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-16 14:07 [PATCH 00/15] Protect the block layer with a rwlock: part 3 Emanuele Giuseppe Esposito
2022-11-16 14:07 ` [PATCH 01/15] block/qed: add missing graph rdlock in qed_need_check_timer_entry Emanuele Giuseppe Esposito
2022-11-16 14:07 ` [PATCH 02/15] block: rename refresh_total_sectors in bdrv_refresh_total_sectors Emanuele Giuseppe Esposito
2022-11-16 14:07 ` [PATCH 03/15] block-backend: use bdrv_getlength instead of blk_getlength Emanuele Giuseppe Esposito
2022-11-16 14:07 ` [PATCH 04/15] block: convert bdrv_refresh_total_sectors in generated_co_wrapper Emanuele Giuseppe Esposito
2022-11-16 14:07 ` [PATCH 05/15] block: use bdrv_co_refresh_total_sectors when possible Emanuele Giuseppe Esposito
2022-11-16 14:07 ` [PATCH 06/15] block: convert bdrv_get_allocated_file_size in generated_co_wrapper_simple Emanuele Giuseppe Esposito
2022-11-16 14:07 ` [PATCH 07/15] block: convert bdrv_get_info in generated_co_wrapper Emanuele Giuseppe Esposito
2022-11-16 14:07 ` [PATCH 08/15] block: convert bdrv_is_inserted in generated_co_wrapper_simple Emanuele Giuseppe Esposito
2022-11-16 14:07 ` [PATCH 09/15] block-coroutine-wrapper: support void functions Emanuele Giuseppe Esposito
2022-11-16 14:07 ` [PATCH 10/15] block: convert bdrv_eject in generated_co_wrapper_simple Emanuele Giuseppe Esposito
2022-11-16 14:07 ` [PATCH 11/15] block: convert bdrv_lock_medium " Emanuele Giuseppe Esposito
2022-11-16 14:07 ` [PATCH 12/15] block: convert bdrv_debug_event in generated_co_wrapper Emanuele Giuseppe Esposito
2022-11-16 14:07 ` [PATCH 13/15] block: convert bdrv_io_plug in generated_co_wrapper_simple Emanuele Giuseppe Esposito
2022-11-16 14:07 ` [PATCH 14/15] block: convert bdrv_io_unplug " Emanuele Giuseppe Esposito
2022-11-16 14:07 ` [PATCH 15/15] block: rename newly converted BlockDriver IO coroutine functions Emanuele Giuseppe Esposito
2022-11-18 10:57 ` [PATCH 00/15] Protect the block layer with a rwlock: part 3 Paolo Bonzini
2022-11-18 15:01   ` Emanuele Giuseppe Esposito
2022-11-18 15:13     ` Paolo Bonzini
2022-11-23 11:45   ` Emanuele Giuseppe Esposito
2022-11-23 13:45     ` Kevin Wolf
2022-11-23 17:04       ` Paolo Bonzini
2022-11-23 18:12         ` Kevin Wolf
2022-11-21 15:02 ` Emanuele Giuseppe Esposito

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).