[PATCH v2 00/21] Graph locking part 4 (node management)

Kevin Wolf posted 21 patches 7 months, 2 weeks ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20230911094620.45040-1-kwolf@redhat.com
Maintainers: Kevin Wolf <kwolf@redhat.com>, Hanna Reitz <hreitz@redhat.com>, Ari Sundholm <ari@tuxera.com>, Stefan Hajnoczi <stefanha@redhat.com>, John Snow <jsnow@redhat.com>, Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>, 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/block-common.h                |   4 +
include/block/block-global-state.h          |  30 +-
include/block/block_int-common.h            |  34 +-
include/block/block_int-global-state.h      |  14 +-
include/sysemu/block-backend-global-state.h |   4 +-
block.c                                     | 348 ++++++++++++++------
block/blklogwrites.c                        |   4 +
block/blkverify.c                           |   2 +
block/block-backend.c                       |  29 +-
block/copy-before-write.c                   |  10 +-
block/crypto.c                              |   6 +-
block/graph-lock.c                          |  26 +-
block/mirror.c                              |   8 +
block/preallocate.c                         | 133 +++++---
block/qcow2.c                               |   4 +-
block/quorum.c                              |  23 +-
block/replication.c                         |   9 +
block/snapshot.c                            |   2 +
block/stream.c                              |  20 +-
block/vmdk.c                                |  13 +
blockdev.c                                  |  23 +-
blockjob.c                                  |   2 +
tests/unit/test-bdrv-drain.c                |  23 +-
tests/unit/test-bdrv-graph-mod.c            |  20 ++
tests/unit/test-block-iothread.c            |   3 +
scripts/block-coroutine-wrapper.py          |  18 +-
tests/qemu-iotests/051.pc.out               |   6 +-
27 files changed, 591 insertions(+), 227 deletions(-)
[PATCH v2 00/21] Graph locking part 4 (node management)
Posted by Kevin Wolf 7 months, 2 weeks ago
The previous parts of the graph locking changes focussed mostly on the
BlockDriver side and taking reader locks while performing I/O. This
series focusses more on the functions managing the graph structure, i.e
adding, removing and replacing nodes and updating their permissions.

Many of these places actually need to take the writer lock to avoid
readers seeing an inconsistent half-updated graph state. Therefore
taking the writer lock is now moved from the very low-level function
bdrv_replace_child_noperm() into its more high level callers.

v2:
- Patch 5: Improved comments, added one for bdrv_schedule_unref()

Kevin Wolf (21):
  block: Remove unused BlockReopenQueueEntry.perms_checked
  preallocate: Factor out preallocate_truncate_to_real_size()
  preallocate: Don't poll during permission updates
  block: Take AioContext lock for bdrv_append() more consistently
  block: Introduce bdrv_schedule_unref()
  block-coroutine-wrapper: Add no_co_wrapper_bdrv_wrlock functions
  block-coroutine-wrapper: Allow arbitrary parameter names
  block: Mark bdrv_replace_child_noperm() GRAPH_WRLOCK
  block: Mark bdrv_replace_child_tran() GRAPH_WRLOCK
  block: Mark bdrv_attach_child_common() GRAPH_WRLOCK
  block: Call transaction callbacks with lock held
  block: Mark bdrv_attach_child() GRAPH_WRLOCK
  block: Mark bdrv_parent_perms_conflict() and callers GRAPH_RDLOCK
  block: Mark bdrv_get_cumulative_perm() and callers GRAPH_RDLOCK
  block: Mark bdrv_child_perm() GRAPH_RDLOCK
  block: Mark bdrv_parent_cb_change_media() GRAPH_RDLOCK
  block: Take graph rdlock in bdrv_drop_intermediate()
  block: Take graph rdlock in bdrv_change_aio_context()
  block: Mark bdrv_root_unref_child() GRAPH_WRLOCK
  block: Mark bdrv_unref_child() GRAPH_WRLOCK
  block: Mark bdrv_add/del_child() and caller GRAPH_WRLOCK

 include/block/block-common.h                |   4 +
 include/block/block-global-state.h          |  30 +-
 include/block/block_int-common.h            |  34 +-
 include/block/block_int-global-state.h      |  14 +-
 include/sysemu/block-backend-global-state.h |   4 +-
 block.c                                     | 348 ++++++++++++++------
 block/blklogwrites.c                        |   4 +
 block/blkverify.c                           |   2 +
 block/block-backend.c                       |  29 +-
 block/copy-before-write.c                   |  10 +-
 block/crypto.c                              |   6 +-
 block/graph-lock.c                          |  26 +-
 block/mirror.c                              |   8 +
 block/preallocate.c                         | 133 +++++---
 block/qcow2.c                               |   4 +-
 block/quorum.c                              |  23 +-
 block/replication.c                         |   9 +
 block/snapshot.c                            |   2 +
 block/stream.c                              |  20 +-
 block/vmdk.c                                |  13 +
 blockdev.c                                  |  23 +-
 blockjob.c                                  |   2 +
 tests/unit/test-bdrv-drain.c                |  23 +-
 tests/unit/test-bdrv-graph-mod.c            |  20 ++
 tests/unit/test-block-iothread.c            |   3 +
 scripts/block-coroutine-wrapper.py          |  18 +-
 tests/qemu-iotests/051.pc.out               |   6 +-
 27 files changed, 591 insertions(+), 227 deletions(-)

-- 
2.41.0
Re: [PATCH v2 00/21] Graph locking part 4 (node management)
Posted by Stefan Hajnoczi 7 months, 2 weeks ago
On Mon, Sep 11, 2023 at 11:45:59AM +0200, Kevin Wolf wrote:
> The previous parts of the graph locking changes focussed mostly on the
> BlockDriver side and taking reader locks while performing I/O. This
> series focusses more on the functions managing the graph structure, i.e
> adding, removing and replacing nodes and updating their permissions.
> 
> Many of these places actually need to take the writer lock to avoid
> readers seeing an inconsistent half-updated graph state. Therefore
> taking the writer lock is now moved from the very low-level function
> bdrv_replace_child_noperm() into its more high level callers.
> 
> v2:
> - Patch 5: Improved comments, added one for bdrv_schedule_unref()
> 
> Kevin Wolf (21):
>   block: Remove unused BlockReopenQueueEntry.perms_checked
>   preallocate: Factor out preallocate_truncate_to_real_size()
>   preallocate: Don't poll during permission updates
>   block: Take AioContext lock for bdrv_append() more consistently
>   block: Introduce bdrv_schedule_unref()
>   block-coroutine-wrapper: Add no_co_wrapper_bdrv_wrlock functions
>   block-coroutine-wrapper: Allow arbitrary parameter names
>   block: Mark bdrv_replace_child_noperm() GRAPH_WRLOCK
>   block: Mark bdrv_replace_child_tran() GRAPH_WRLOCK
>   block: Mark bdrv_attach_child_common() GRAPH_WRLOCK
>   block: Call transaction callbacks with lock held
>   block: Mark bdrv_attach_child() GRAPH_WRLOCK
>   block: Mark bdrv_parent_perms_conflict() and callers GRAPH_RDLOCK
>   block: Mark bdrv_get_cumulative_perm() and callers GRAPH_RDLOCK
>   block: Mark bdrv_child_perm() GRAPH_RDLOCK
>   block: Mark bdrv_parent_cb_change_media() GRAPH_RDLOCK
>   block: Take graph rdlock in bdrv_drop_intermediate()
>   block: Take graph rdlock in bdrv_change_aio_context()
>   block: Mark bdrv_root_unref_child() GRAPH_WRLOCK
>   block: Mark bdrv_unref_child() GRAPH_WRLOCK
>   block: Mark bdrv_add/del_child() and caller GRAPH_WRLOCK
> 
>  include/block/block-common.h                |   4 +
>  include/block/block-global-state.h          |  30 +-
>  include/block/block_int-common.h            |  34 +-
>  include/block/block_int-global-state.h      |  14 +-
>  include/sysemu/block-backend-global-state.h |   4 +-
>  block.c                                     | 348 ++++++++++++++------
>  block/blklogwrites.c                        |   4 +
>  block/blkverify.c                           |   2 +
>  block/block-backend.c                       |  29 +-
>  block/copy-before-write.c                   |  10 +-
>  block/crypto.c                              |   6 +-
>  block/graph-lock.c                          |  26 +-
>  block/mirror.c                              |   8 +
>  block/preallocate.c                         | 133 +++++---
>  block/qcow2.c                               |   4 +-
>  block/quorum.c                              |  23 +-
>  block/replication.c                         |   9 +
>  block/snapshot.c                            |   2 +
>  block/stream.c                              |  20 +-
>  block/vmdk.c                                |  13 +
>  blockdev.c                                  |  23 +-
>  blockjob.c                                  |   2 +
>  tests/unit/test-bdrv-drain.c                |  23 +-
>  tests/unit/test-bdrv-graph-mod.c            |  20 ++
>  tests/unit/test-block-iothread.c            |   3 +
>  scripts/block-coroutine-wrapper.py          |  18 +-
>  tests/qemu-iotests/051.pc.out               |   6 +-
>  27 files changed, 591 insertions(+), 227 deletions(-)

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Re: [PATCH v2 00/21] Graph locking part 4 (node management)
Posted by Kevin Wolf 7 months, 2 weeks ago
Am 12.09.2023 um 18:49 hat Stefan Hajnoczi geschrieben:
> On Mon, Sep 11, 2023 at 11:45:59AM +0200, Kevin Wolf wrote:
> > The previous parts of the graph locking changes focussed mostly on the
> > BlockDriver side and taking reader locks while performing I/O. This
> > series focusses more on the functions managing the graph structure, i.e
> > adding, removing and replacing nodes and updating their permissions.
> > 
> > Many of these places actually need to take the writer lock to avoid
> > readers seeing an inconsistent half-updated graph state. Therefore
> > taking the writer lock is now moved from the very low-level function
> > bdrv_replace_child_noperm() into its more high level callers.
> > 
> > v2:
> > - Patch 5: Improved comments, added one for bdrv_schedule_unref()
> > 
> > Kevin Wolf (21):
> >   block: Remove unused BlockReopenQueueEntry.perms_checked
> >   preallocate: Factor out preallocate_truncate_to_real_size()
> >   preallocate: Don't poll during permission updates
> >   block: Take AioContext lock for bdrv_append() more consistently
> >   block: Introduce bdrv_schedule_unref()
> >   block-coroutine-wrapper: Add no_co_wrapper_bdrv_wrlock functions
> >   block-coroutine-wrapper: Allow arbitrary parameter names
> >   block: Mark bdrv_replace_child_noperm() GRAPH_WRLOCK
> >   block: Mark bdrv_replace_child_tran() GRAPH_WRLOCK
> >   block: Mark bdrv_attach_child_common() GRAPH_WRLOCK
> >   block: Call transaction callbacks with lock held
> >   block: Mark bdrv_attach_child() GRAPH_WRLOCK
> >   block: Mark bdrv_parent_perms_conflict() and callers GRAPH_RDLOCK
> >   block: Mark bdrv_get_cumulative_perm() and callers GRAPH_RDLOCK
> >   block: Mark bdrv_child_perm() GRAPH_RDLOCK
> >   block: Mark bdrv_parent_cb_change_media() GRAPH_RDLOCK
> >   block: Take graph rdlock in bdrv_drop_intermediate()
> >   block: Take graph rdlock in bdrv_change_aio_context()
> >   block: Mark bdrv_root_unref_child() GRAPH_WRLOCK
> >   block: Mark bdrv_unref_child() GRAPH_WRLOCK
> >   block: Mark bdrv_add/del_child() and caller GRAPH_WRLOCK
> > 
> >  include/block/block-common.h                |   4 +
> >  include/block/block-global-state.h          |  30 +-
> >  include/block/block_int-common.h            |  34 +-
> >  include/block/block_int-global-state.h      |  14 +-
> >  include/sysemu/block-backend-global-state.h |   4 +-
> >  block.c                                     | 348 ++++++++++++++------
> >  block/blklogwrites.c                        |   4 +
> >  block/blkverify.c                           |   2 +
> >  block/block-backend.c                       |  29 +-
> >  block/copy-before-write.c                   |  10 +-
> >  block/crypto.c                              |   6 +-
> >  block/graph-lock.c                          |  26 +-
> >  block/mirror.c                              |   8 +
> >  block/preallocate.c                         | 133 +++++---
> >  block/qcow2.c                               |   4 +-
> >  block/quorum.c                              |  23 +-
> >  block/replication.c                         |   9 +
> >  block/snapshot.c                            |   2 +
> >  block/stream.c                              |  20 +-
> >  block/vmdk.c                                |  13 +
> >  blockdev.c                                  |  23 +-
> >  blockjob.c                                  |   2 +
> >  tests/unit/test-bdrv-drain.c                |  23 +-
> >  tests/unit/test-bdrv-graph-mod.c            |  20 ++
> >  tests/unit/test-block-iothread.c            |   3 +
> >  scripts/block-coroutine-wrapper.py          |  18 +-
> >  tests/qemu-iotests/051.pc.out               |   6 +-
> >  27 files changed, 591 insertions(+), 227 deletions(-)
> 
> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>

Thanks, applied to the block branch.

Kevin