[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC PATCH v2 21/25] block_int-common.h: split function pointers in Bdrv
From: |
Emanuele Giuseppe Esposito |
Subject: |
[RFC PATCH v2 21/25] block_int-common.h: split function pointers in BdrvChildClass |
Date: |
Tue, 5 Oct 2021 10:32:11 -0400 |
Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
---
include/block/block_int-common.h | 65 ++++++++++++++++++++++----------
1 file changed, 46 insertions(+), 19 deletions(-)
diff --git a/include/block/block_int-common.h b/include/block/block_int-common.h
index 184cfab2d6..a6ea824b64 100644
--- a/include/block/block_int-common.h
+++ b/include/block/block_int-common.h
@@ -798,12 +798,31 @@ struct BdrvChildClass {
*/
bool parent_is_bds;
+ /*
+ * 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 callers that use these function pointers must
+ * use this assertion:
+ * g_assert(qemu_in_main_thread());
+ * to catch when they are accidentally called without the BQL.
+ */
void (*inherit_options)(BdrvChildRole role, bool parent_is_format,
int *child_flags, QDict *child_options,
int parent_flags, QDict *parent_options);
-
void (*change_media)(BdrvChild *child, bool load);
- void (*resize)(BdrvChild *child);
/*
* Returns a name that is supposedly more useful for human users than the
@@ -820,6 +839,31 @@ struct BdrvChildClass {
*/
char *(*get_parent_desc)(BdrvChild *child);
+ void (*attach)(BdrvChild *child);
+ void (*detach)(BdrvChild *child);
+
+ /*
+ * Notifies the parent that the filename of its child has changed (e.g.
+ * because the direct child was removed from the backing chain), so that it
+ * can update its reference.
+ */
+ int (*update_filename)(BdrvChild *child, BlockDriverState *new_base,
+ const char *filename, Error **errp);
+
+ bool (*can_set_aio_ctx)(BdrvChild *child, AioContext *ctx,
+ GSList **ignore, Error **errp);
+ void (*set_aio_ctx)(BdrvChild *child, AioContext *ctx, GSList **ignore);
+
+ AioContext *(*get_parent_aio_context)(BdrvChild *child);
+
+ /*
+ * I/O API functions. These functions are thread-safe, and therefore
+ * can run in any thread as long as they have called
+ * aio_context_acquire/release().
+ */
+
+ void (*resize)(BdrvChild *child);
+
/*
* If this pair of functions is implemented, the parent doesn't issue new
* requests after returning from .drained_begin() until .drained_end() is
@@ -852,23 +896,6 @@ struct BdrvChildClass {
*/
void (*activate)(BdrvChild *child, Error **errp);
int (*inactivate)(BdrvChild *child);
-
- void (*attach)(BdrvChild *child);
- void (*detach)(BdrvChild *child);
-
- /*
- * Notifies the parent that the filename of its child has changed (e.g.
- * because the direct child was removed from the backing chain), so that it
- * can update its reference.
- */
- int (*update_filename)(BdrvChild *child, BlockDriverState *new_base,
- const char *filename, Error **errp);
-
- bool (*can_set_aio_ctx)(BdrvChild *child, AioContext *ctx,
- GSList **ignore, Error **errp);
- void (*set_aio_ctx)(BdrvChild *child, AioContext *ctx, GSList **ignore);
-
- AioContext *(*get_parent_aio_context)(BdrvChild *child);
};
extern const BdrvChildClass child_of_bds;
--
2.27.0
- [RFC PATCH v2 17/25] include/block/transactions: global state API + assertions, (continued)
- [RFC PATCH v2 17/25] include/block/transactions: global state API + assertions, Emanuele Giuseppe Esposito, 2021/10/05
- [RFC PATCH v2 15/25] include/block/snapshot: global state API + assertions, Emanuele Giuseppe Esposito, 2021/10/05
- [RFC PATCH v2 19/25] block_int-common.h: split function pointers in BlockDriver, Emanuele Giuseppe Esposito, 2021/10/05
- [RFC PATCH v2 20/25] block_int-common.h: assertion in the callers of BlockDriver function pointers, Emanuele Giuseppe Esposito, 2021/10/05
- [RFC PATCH v2 21/25] block_int-common.h: split function pointers in BdrvChildClass,
Emanuele Giuseppe Esposito <=
- [RFC PATCH v2 22/25] block_int-common.h: assertions in the callers of BdrvChildClass function pointers, Emanuele Giuseppe Esposito, 2021/10/05
- [RFC PATCH v2 24/25] job.h: split function pointers in JobDriver, Emanuele Giuseppe Esposito, 2021/10/05
- [RFC PATCH v2 25/25] job.h: assertions in the callers of JobDriver funcion pointers, Emanuele Giuseppe Esposito, 2021/10/05
- [RFC PATCH v2 23/25] block-backend-common.h: split function pointers in BlockDevOps, Emanuele Giuseppe Esposito, 2021/10/05