[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [RFC PATCH v2 7/8] graph-lock: implement WITH_GRAPH_RDLOCK_GUARD and
From: |
Stefan Hajnoczi |
Subject: |
Re: [RFC PATCH v2 7/8] graph-lock: implement WITH_GRAPH_RDLOCK_GUARD and GRAPH_RDLOCK_GUARD macros |
Date: |
Thu, 28 Apr 2022 16:00:45 +0100 |
On Tue, Apr 26, 2022 at 04:51:13AM -0400, Emanuele Giuseppe Esposito wrote:
> Similar to the implementation in lockable.h, implement macros to
> automatically take and release the rdlock.
> Create the empty GraphLockable struct only to use it as a type for
> G_DEFINE_AUTOPTR_CLEANUP_FUNC.
>
> Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
> ---
> include/block/graph-lock.h | 30 ++++++++++++++++++++++++++++++
> 1 file changed, 30 insertions(+)
>
> diff --git a/include/block/graph-lock.h b/include/block/graph-lock.h
> index 2211d41286..8d8a6513f1 100644
> --- a/include/block/graph-lock.h
> +++ b/include/block/graph-lock.h
> @@ -67,5 +67,35 @@ void assert_bdrv_graph_readable(void);
> */
> void assert_bdrv_graph_writable(void);
>
> +typedef struct GraphLockable { } GraphLockable;
> +
> +#define GML_OBJ_() (&(GraphLockable) { })
The comment for QML_OBJ_() is helpful. This takes advantage of the
lifetime of compound literals and it's different in C and C++. I suggest
keeping it for the benefit for people trying to understand how this
works.
signature.asc
Description: PGP signature
- Re: [RFC PATCH v2 2/8] coroutine-lock: release lock when restarting all coroutines, (continued)
[RFC PATCH v2 1/8] aio_wait_kick: add missing memory barrier, Emanuele Giuseppe Esposito, 2022/04/26
Re: [RFC PATCH v2 1/8] aio_wait_kick: add missing memory barrier, Paolo Bonzini, 2022/04/29
[RFC PATCH v2 7/8] graph-lock: implement WITH_GRAPH_RDLOCK_GUARD and GRAPH_RDLOCK_GUARD macros, Emanuele Giuseppe Esposito, 2022/04/26
- Re: [RFC PATCH v2 7/8] graph-lock: implement WITH_GRAPH_RDLOCK_GUARD and GRAPH_RDLOCK_GUARD macros,
Stefan Hajnoczi <=
[RFC PATCH v2 4/8] async: register/unregister aiocontext in graph lock list, Emanuele Giuseppe Esposito, 2022/04/26
[RFC PATCH v2 3/8] block: introduce a lock to protect graph operations, Emanuele Giuseppe Esposito, 2022/04/26
[RFC PATCH v2 8/8] mirror: protect drains in coroutine with rdlock, Emanuele Giuseppe Esposito, 2022/04/26