[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [RFC PATCH v2 11/25] include/block/blockjob.h: global state API
From: |
Stefan Hajnoczi |
Subject: |
Re: [RFC PATCH v2 11/25] include/block/blockjob.h: global state API |
Date: |
Thu, 7 Oct 2021 15:23:53 +0100 |
On Tue, Oct 05, 2021 at 10:32:01AM -0400, Emanuele Giuseppe Esposito wrote:
> blockjob functions run always under the BQL lock.
>
> Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
> ---
> include/block/blockjob.h | 23 +++++++++++++++++++++++
> 1 file changed, 23 insertions(+)
>
> diff --git a/include/block/blockjob.h b/include/block/blockjob.h
> index d200f33c10..3bf384f8bf 100644
> --- a/include/block/blockjob.h
> +++ b/include/block/blockjob.h
> @@ -77,6 +77,27 @@ typedef struct BlockJob {
> GSList *nodes;
> } BlockJob;
>
> +/*
> + * Global state (GS) API. These functions run under the BQL lock.
> + *
> + * If a function modifies the graph, it also uses drain and/or
> + * aio_context_acquire/release to be sure it has unique access.
> + * aio_context locking is needed together with BQL because of
> + * the thread-safe I/O API that concurrently runs and accesses
> + * the graph without the BQL.
> + *
> + * It is important to note that not all of these functions are
> + * necessarily limited to running under the BQL, but they would
> + * require additional auditing and may small thread-safety changes
> + * to move them into the I/O API. Often it's not worth doing that
> + * work since the APIs are only used with the BQL held at the
> + * moment, so they have been placed in the GS API (for now).
> + *
> + * All functions below must use this assertion:
> + * g_assert(qemu_in_main_thread());
> + * to catch when they are accidentally called without the BQL.
> + */
This is comment is duplicated in many places. I suggest explaining it in
one place and using references in the other files:
/*
* Global state (GS) API. These functions run under the BQL lock.
*
* See include/block/block.h for more information about the GS API.
*/
signature.asc
Description: PGP signature
- [RFC PATCH v2 10/25] assertions for blockjob_int.h, (continued)
- [RFC PATCH v2 10/25] assertions for blockjob_int.h, Emanuele Giuseppe Esposito, 2021/10/05
- [RFC PATCH v2 12/25] assertions for blockob.h global state API, Emanuele Giuseppe Esposito, 2021/10/05
- [RFC PATCH v2 09/25] include/block/blockjob_int.h: split header into I/O and GS API, Emanuele Giuseppe Esposito, 2021/10/05
- [RFC PATCH v2 13/25] include/systemu/blockdev.h: global state API, Emanuele Giuseppe Esposito, 2021/10/05
- [RFC PATCH v2 11/25] include/block/blockjob.h: global state API, Emanuele Giuseppe Esposito, 2021/10/05
- Re: [RFC PATCH v2 11/25] include/block/blockjob.h: global state API,
Stefan Hajnoczi <=
- [RFC PATCH v2 14/25] assertions for blockdev.h global state API, Emanuele Giuseppe Esposito, 2021/10/05
- [RFC PATCH v2 16/25] block/backup-top.h: global state API + assertions, Emanuele Giuseppe Esposito, 2021/10/05
- [RFC PATCH v2 18/25] block/coroutines: I/O API, Emanuele Giuseppe Esposito, 2021/10/05