[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC PATCH v2 13/25] include/systemu/blockdev.h: global state API
From: |
Emanuele Giuseppe Esposito |
Subject: |
[RFC PATCH v2 13/25] include/systemu/blockdev.h: global state API |
Date: |
Tue, 5 Oct 2021 10:32:03 -0400 |
blockdev functions run always under the BQL lock.
Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
---
include/sysemu/blockdev.h | 35 ++++++++++++++++++++++++++++++-----
1 file changed, 30 insertions(+), 5 deletions(-)
diff --git a/include/sysemu/blockdev.h b/include/sysemu/blockdev.h
index 32c2d6023c..28233f6b63 100644
--- a/include/sysemu/blockdev.h
+++ b/include/sysemu/blockdev.h
@@ -38,24 +38,49 @@ struct DriveInfo {
QTAILQ_ENTRY(DriveInfo) next;
};
-DriveInfo *blk_legacy_dinfo(BlockBackend *blk);
+/*
+ * 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 in this header must use this assertion:
+ * g_assert(qemu_in_main_thread());
+ * to catch when they are accidentally called without the BQL.
+ */
+
DriveInfo *blk_set_legacy_dinfo(BlockBackend *blk, DriveInfo *dinfo);
BlockBackend *blk_by_legacy_dinfo(DriveInfo *dinfo);
void override_max_devs(BlockInterfaceType type, int max_devs);
DriveInfo *drive_get(BlockInterfaceType type, int bus, int unit);
-void drive_mark_claimed_by_board(void);
void drive_check_orphaned(void);
DriveInfo *drive_get_by_index(BlockInterfaceType type, int index);
int drive_get_max_bus(BlockInterfaceType type);
-int drive_get_max_devs(BlockInterfaceType type);
DriveInfo *drive_get_next(BlockInterfaceType type);
+DriveInfo *drive_new(QemuOpts *arg, BlockInterfaceType block_default_type,
+ Error **errp);
+
+/* Common functions that are neither I/O nor Global State */
+
+DriveInfo *blk_legacy_dinfo(BlockBackend *blk);
+int drive_get_max_devs(BlockInterfaceType type);
+
QemuOpts *drive_def(const char *optstr);
+
QemuOpts *drive_add(BlockInterfaceType type, int index, const char *file,
const char *optstr);
-DriveInfo *drive_new(QemuOpts *arg, BlockInterfaceType block_default_type,
- Error **errp);
#endif
--
2.27.0
- Re: [RFC PATCH v2 08/25] block: introduce assert_bdrv_graph_writable, (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 <=
[RFC PATCH v2 11/25] include/block/blockjob.h: global state API, Emanuele Giuseppe Esposito, 2021/10/05
[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