[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 08/20] block: .bdrv_open is non-coroutine and unlocked
From: |
Eric Blake |
Subject: |
Re: [PATCH 08/20] block: .bdrv_open is non-coroutine and unlocked |
Date: |
Tue, 25 Apr 2023 16:04:00 -0500 |
User-agent: |
NeoMutt/20230407 |
On Tue, Apr 25, 2023 at 07:31:46PM +0200, Kevin Wolf wrote:
> Drivers were a bit confused about whether .bdrv_open can run in a
> coroutine and whether or not it holds a graph lock.
>
> It cannot keep a graph lock from the caller across the whole function
> because it both changes the graph (requires a writer lock) and does I/O
> (requires a reader lock). Therefore, it should take these locks
> internally as needed.
>
> The functions used to be called in coroutine context during image
> creation. This was buggy for other reasons, and as of commit 32192301,
> all block drivers go through no_co_wrappers. So it is not called in
> coroutine context any more.
>
> Fix qcow2 and qed to work with the correct assumptions: The graph lock
> needs to be taken internally instead of just assuming it's already
> there, and the coroutine path is dead code that can be removed.
>
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
> include/block/block_int-common.h | 8 ++++----
> block.c | 6 +++---
> block/qcow2.c | 15 ++++++---------
> block/qed.c | 18 ++++++++----------
> 4 files changed, 21 insertions(+), 26 deletions(-)
>
> diff --git a/include/block/block_int-common.h
> b/include/block/block_int-common.h
> index 013d419444..6fb28cd8fa 100644
> --- a/include/block/block_int-common.h
> +++ b/include/block/block_int-common.h
> @@ -236,12 +236,12 @@ struct BlockDriver {
> void (*bdrv_reopen_abort)(BDRVReopenState *reopen_state);
> void (*bdrv_join_options)(QDict *options, QDict *old_options);
>
> - int (*bdrv_open)(BlockDriverState *bs, QDict *options, int flags,
> - Error **errp);
> + int GRAPH_UNLOCKED_PTR (*bdrv_open)(
> + BlockDriverState *bs, QDict *options, int flags, Error **errp);
>
> /* Protocol drivers should implement this instead of bdrv_open */
> - int (*bdrv_file_open)(BlockDriverState *bs, QDict *options, int flags,
> - Error **errp);
> + int GRAPH_UNLOCKED_PTR (*bdrv_file_open)(
> + BlockDriverState *bs, QDict *options, int flags, Error **errp);
May conflict with Paolo's work to eliminate bdrv_file_open as
redundant. But that should be easy to figure out.
Reviewed-by: Eric Blake <eblake@redhat.com>
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org
- Re: [PATCH 07/20] graph-lock: Fix GRAPH_RDLOCK_GUARD*() to be reader lock, (continued)
- [PATCH 15/20] block: Mark bdrv_co_debug_event() GRAPH_RDLOCK, Kevin Wolf, 2023/04/25
- [PATCH 11/20] vhdx: Take graph lock for accessing a node's parent list, Kevin Wolf, 2023/04/25
- [PATCH 13/20] block: Mark bdrv_co_get_allocated_file_size() and callers GRAPH_RDLOCK, Kevin Wolf, 2023/04/25
- [PATCH 14/20] block: Mark bdrv_co_get_info() and callers GRAPH_RDLOCK, Kevin Wolf, 2023/04/25
- [PATCH 08/20] block: .bdrv_open is non-coroutine and unlocked, Kevin Wolf, 2023/04/25
- Re: [PATCH 08/20] block: .bdrv_open is non-coroutine and unlocked,
Eric Blake <=
- [PATCH 09/20] nbd: Remove nbd_co_flush() wrapper function, Kevin Wolf, 2023/04/25
- [PATCH 12/20] mirror: Take graph lock for accessing a node's parent list, Kevin Wolf, 2023/04/25
- [PATCH 18/20] block: Mark bdrv_query_block_graph_info() and callers GRAPH_RDLOCK, Kevin Wolf, 2023/04/25
- [PATCH 19/20] block: Mark bdrv_recurse_can_replace() and callers GRAPH_RDLOCK, Kevin Wolf, 2023/04/25
- [PATCH 20/20] block: Mark bdrv_refresh_limits() and callers GRAPH_RDLOCK, Kevin Wolf, 2023/04/25