|
@@ -53,18 +53,12 @@ struct LinuxAioState;
|
|
|
struct AioContext {
|
|
|
GSource source;
|
|
|
|
|
|
- /* Protects all fields from multi-threaded access */
|
|
|
+ /* Used by AioContext users to protect from multi-threaded access. */
|
|
|
QemuRecMutex lock;
|
|
|
|
|
|
- /* The list of registered AIO handlers */
|
|
|
+ /* The list of registered AIO handlers. Protected by ctx->list_lock. */
|
|
|
QLIST_HEAD(, AioHandler) aio_handlers;
|
|
|
|
|
|
- /* This is a simple lock used to protect the aio_handlers list.
|
|
|
- * Specifically, it's used to ensure that no callbacks are removed while
|
|
|
- * we're walking and dispatching callbacks.
|
|
|
- */
|
|
|
- int walking_handlers;
|
|
|
-
|
|
|
/* Used to avoid unnecessary event_notifier_set calls in aio_notify;
|
|
|
* accessed with atomic primitives. If this field is 0, everything
|
|
|
* (file descriptors, bottom halves, timers) will be re-evaluated
|
|
@@ -90,9 +84,9 @@ struct AioContext {
|
|
|
*/
|
|
|
uint32_t notify_me;
|
|
|
|
|
|
- /* A lock to protect between bh's adders and deleter, and to ensure
|
|
|
- * that no callbacks are removed while we're walking and dispatching
|
|
|
- * them.
|
|
|
+ /* A lock to protect between QEMUBH and AioHandler adders and deleter,
|
|
|
+ * and to ensure that no callbacks are removed while we're walking and
|
|
|
+ * dispatching them.
|
|
|
*/
|
|
|
QemuLockCnt list_lock;
|
|
|
|
|
@@ -114,7 +108,9 @@ struct AioContext {
|
|
|
bool notified;
|
|
|
EventNotifier notifier;
|
|
|
|
|
|
- /* Thread pool for performing work and receiving completion callbacks */
|
|
|
+ /* Thread pool for performing work and receiving completion callbacks.
|
|
|
+ * Has its own locking.
|
|
|
+ */
|
|
|
struct ThreadPool *thread_pool;
|
|
|
|
|
|
#ifdef CONFIG_LINUX_AIO
|
|
@@ -124,7 +120,9 @@ struct AioContext {
|
|
|
struct LinuxAioState *linux_aio;
|
|
|
#endif
|
|
|
|
|
|
- /* TimerLists for calling timers - one per clock type */
|
|
|
+ /* TimerLists for calling timers - one per clock type. Has its own
|
|
|
+ * locking.
|
|
|
+ */
|
|
|
QEMUTimerListGroup tlg;
|
|
|
|
|
|
int external_disable_cnt;
|
|
@@ -178,9 +176,11 @@ void aio_context_unref(AioContext *ctx);
|
|
|
* automatically takes care of calling aio_context_acquire and
|
|
|
* aio_context_release.
|
|
|
*
|
|
|
- * Access to timers and BHs from a thread that has not acquired AioContext
|
|
|
- * is possible. Access to callbacks for now must be done while the AioContext
|
|
|
- * is owned by the thread (FIXME).
|
|
|
+ * Note that this is separate from bdrv_drained_begin/bdrv_drained_end. A
|
|
|
+ * thread still has to call those to avoid being interrupted by the guest.
|
|
|
+ *
|
|
|
+ * Bottom halves, timers and callbacks can be created or removed without
|
|
|
+ * acquiring the AioContext.
|
|
|
*/
|
|
|
void aio_context_acquire(AioContext *ctx);
|
|
|
|