[PATCH for-8.2 0/4] block: Fix deadlocks with the stream job

Kevin Wolf posted 4 patches 1 year ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20231115172012.112727-1-kwolf@redhat.com
Maintainers: Kevin Wolf <kwolf@redhat.com>, Hanna Reitz <hreitz@redhat.com>, John Snow <jsnow@redhat.com>, Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>, Ari Sundholm <ari@tuxera.com>, Stefan Hajnoczi <stefanha@redhat.com>, Alberto Garcia <berto@igalia.com>, Wen Congyang <wencongyang2@huawei.com>, Xie Changlong <xiechanglong.d@gmail.com>, Fam Zheng <fam@euphon.net>, Cleber Rosa <crosa@redhat.com>
include/block/graph-lock.h                    | 15 +++-
block.c                                       | 26 +++----
block/backup.c                                |  2 +-
block/blklogwrites.c                          |  4 +-
block/blkverify.c                             |  2 +-
block/block-backend.c                         | 10 ++-
block/commit.c                                | 10 +--
block/graph-lock.c                            | 23 +++++-
block/mirror.c                                | 14 ++--
block/qcow2.c                                 |  2 +-
block/quorum.c                                |  4 +-
block/replication.c                           | 10 +--
block/snapshot.c                              |  2 +-
block/stream.c                                | 10 +--
block/vmdk.c                                  | 10 +--
blockdev.c                                    |  4 +-
blockjob.c                                    |  8 +-
tests/unit/test-bdrv-drain.c                  | 20 ++---
tests/unit/test-bdrv-graph-mod.c              | 10 +--
scripts/block-coroutine-wrapper.py            |  2 +-
tests/qemu-iotests/tests/iothreads-stream     | 73 +++++++++++++++++++
tests/qemu-iotests/tests/iothreads-stream.out | 11 +++
22 files changed, 197 insertions(+), 75 deletions(-)
create mode 100755 tests/qemu-iotests/tests/iothreads-stream
create mode 100644 tests/qemu-iotests/tests/iothreads-stream.out
[PATCH for-8.2 0/4] block: Fix deadlocks with the stream job
Posted by Kevin Wolf 1 year ago
This series contains three fixes for deadlocks that follow the same
pattern: A nested event loop in the main thread waits for an iothread to
make progress, but the AioContext lock of that iothread is still held by
the main loop, so it can never make progress.

We're planning to fully remove the AioContext lock in 9.0, which would
automatically get rid of this kind of bugs, but it's still there in 8.2,
so let's fix them individually for this release.

Kevin Wolf (4):
  block: Fix bdrv_graph_wrlock() call in blk_remove_bs()
  block: Fix deadlocks in bdrv_graph_wrunlock()
  stream: Fix AioContext locking during bdrv_graph_wrlock()
  iotests: Test two stream jobs in a single iothread

 include/block/graph-lock.h                    | 15 +++-
 block.c                                       | 26 +++----
 block/backup.c                                |  2 +-
 block/blklogwrites.c                          |  4 +-
 block/blkverify.c                             |  2 +-
 block/block-backend.c                         | 10 ++-
 block/commit.c                                | 10 +--
 block/graph-lock.c                            | 23 +++++-
 block/mirror.c                                | 14 ++--
 block/qcow2.c                                 |  2 +-
 block/quorum.c                                |  4 +-
 block/replication.c                           | 10 +--
 block/snapshot.c                              |  2 +-
 block/stream.c                                | 10 +--
 block/vmdk.c                                  | 10 +--
 blockdev.c                                    |  4 +-
 blockjob.c                                    |  8 +-
 tests/unit/test-bdrv-drain.c                  | 20 ++---
 tests/unit/test-bdrv-graph-mod.c              | 10 +--
 scripts/block-coroutine-wrapper.py            |  2 +-
 tests/qemu-iotests/tests/iothreads-stream     | 73 +++++++++++++++++++
 tests/qemu-iotests/tests/iothreads-stream.out | 11 +++
 22 files changed, 197 insertions(+), 75 deletions(-)
 create mode 100755 tests/qemu-iotests/tests/iothreads-stream
 create mode 100644 tests/qemu-iotests/tests/iothreads-stream.out

-- 
2.41.0
Re: [PATCH for-8.2 0/4] block: Fix deadlocks with the stream job
Posted by Stefan Hajnoczi 1 year ago
On Wed, Nov 15, 2023 at 06:20:08PM +0100, Kevin Wolf wrote:
> This series contains three fixes for deadlocks that follow the same
> pattern: A nested event loop in the main thread waits for an iothread to
> make progress, but the AioContext lock of that iothread is still held by
> the main loop, so it can never make progress.
> 
> We're planning to fully remove the AioContext lock in 9.0, which would
> automatically get rid of this kind of bugs, but it's still there in 8.2,
> so let's fix them individually for this release.
> 
> Kevin Wolf (4):
>   block: Fix bdrv_graph_wrlock() call in blk_remove_bs()
>   block: Fix deadlocks in bdrv_graph_wrunlock()
>   stream: Fix AioContext locking during bdrv_graph_wrlock()
>   iotests: Test two stream jobs in a single iothread
> 
>  include/block/graph-lock.h                    | 15 +++-
>  block.c                                       | 26 +++----
>  block/backup.c                                |  2 +-
>  block/blklogwrites.c                          |  4 +-
>  block/blkverify.c                             |  2 +-
>  block/block-backend.c                         | 10 ++-
>  block/commit.c                                | 10 +--
>  block/graph-lock.c                            | 23 +++++-
>  block/mirror.c                                | 14 ++--
>  block/qcow2.c                                 |  2 +-
>  block/quorum.c                                |  4 +-
>  block/replication.c                           | 10 +--
>  block/snapshot.c                              |  2 +-
>  block/stream.c                                | 10 +--
>  block/vmdk.c                                  | 10 +--
>  blockdev.c                                    |  4 +-
>  blockjob.c                                    |  8 +-
>  tests/unit/test-bdrv-drain.c                  | 20 ++---
>  tests/unit/test-bdrv-graph-mod.c              | 10 +--
>  scripts/block-coroutine-wrapper.py            |  2 +-
>  tests/qemu-iotests/tests/iothreads-stream     | 73 +++++++++++++++++++
>  tests/qemu-iotests/tests/iothreads-stream.out | 11 +++
>  22 files changed, 197 insertions(+), 75 deletions(-)
>  create mode 100755 tests/qemu-iotests/tests/iothreads-stream
>  create mode 100644 tests/qemu-iotests/tests/iothreads-stream.out
> 
> -- 
> 2.41.0
> 

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>