aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/block/aio-wait.h22
-rw-r--r--include/block/block.h6
-rw-r--r--include/block/block_int.h3
-rw-r--r--include/block/blockjob.h10
4 files changed, 12 insertions, 29 deletions
diff --git a/include/block/aio-wait.h b/include/block/aio-wait.h
index 600fad183e..afd0ff7eb8 100644
--- a/include/block/aio-wait.h
+++ b/include/block/aio-wait.h
@@ -30,14 +30,15 @@
/**
* AioWait:
*
- * An object that facilitates synchronous waiting on a condition. The main
- * loop can wait on an operation running in an IOThread as follows:
+ * An object that facilitates synchronous waiting on a condition. A single
+ * global AioWait object (global_aio_wait) is used internally.
+ *
+ * The main loop can wait on an operation running in an IOThread as follows:
*
- * AioWait *wait = ...;
* AioContext *ctx = ...;
* MyWork work = { .done = false };
* schedule_my_work_in_iothread(ctx, &work);
- * AIO_WAIT_WHILE(wait, ctx, !work.done);
+ * AIO_WAIT_WHILE(ctx, !work.done);
*
* The IOThread must call aio_wait_kick() to notify the main loop when
* work.done changes:
@@ -46,7 +47,7 @@
* {
* ...
* work.done = true;
- * aio_wait_kick(wait);
+ * aio_wait_kick();
* }
*/
typedef struct {
@@ -54,9 +55,10 @@ typedef struct {
unsigned num_waiters;
} AioWait;
+extern AioWait global_aio_wait;
+
/**
* AIO_WAIT_WHILE:
- * @wait: the aio wait object
* @ctx: the aio context, or NULL if multiple aio contexts (for which the
* caller does not hold a lock) are involved in the polling condition.
* @cond: wait while this conditional expression is true
@@ -72,9 +74,9 @@ typedef struct {
* wait on conditions between two IOThreads since that could lead to deadlock,
* go via the main loop instead.
*/
-#define AIO_WAIT_WHILE(wait, ctx, cond) ({ \
+#define AIO_WAIT_WHILE(ctx, cond) ({ \
bool waited_ = false; \
- AioWait *wait_ = (wait); \
+ AioWait *wait_ = &global_aio_wait; \
AioContext *ctx_ = (ctx); \
/* Increment wait_->num_waiters before evaluating cond. */ \
atomic_inc(&wait_->num_waiters); \
@@ -102,14 +104,12 @@ typedef struct {
/**
* aio_wait_kick:
- * @wait: the aio wait object that should re-evaluate its condition
- *
* Wake up the main thread if it is waiting on AIO_WAIT_WHILE(). During
* synchronous operations performed in an IOThread, the main thread lets the
* IOThread's event loop run, waiting for the operation to complete. A
* aio_wait_kick() call will wake up the main thread.
*/
-void aio_wait_kick(AioWait *wait);
+void aio_wait_kick(void);
/**
* aio_wait_bh_oneshot:
diff --git a/include/block/block.h b/include/block/block.h
index 4e0871aaf9..4edc1e8afa 100644
--- a/include/block/block.h
+++ b/include/block/block.h
@@ -410,13 +410,9 @@ void bdrv_drain_all_begin(void);
void bdrv_drain_all_end(void);
void bdrv_drain_all(void);
-/* Returns NULL when bs == NULL */
-AioWait *bdrv_get_aio_wait(BlockDriverState *bs);
-
#define BDRV_POLL_WHILE(bs, cond) ({ \
BlockDriverState *bs_ = (bs); \
- AIO_WAIT_WHILE(bdrv_get_aio_wait(bs_), \
- bdrv_get_aio_context(bs_), \
+ AIO_WAIT_WHILE(bdrv_get_aio_context(bs_), \
cond); })
int bdrv_pdiscard(BdrvChild *child, int64_t offset, int bytes);
diff --git a/include/block/block_int.h b/include/block/block_int.h
index 4000d2af45..92ecbd866e 100644
--- a/include/block/block_int.h
+++ b/include/block/block_int.h
@@ -794,9 +794,6 @@ struct BlockDriverState {
unsigned int in_flight;
unsigned int serialising_in_flight;
- /* Kicked to signal main loop when a request completes. */
- AioWait wait;
-
/* counter for nested bdrv_io_plug.
* Accessed with atomic ops.
*/
diff --git a/include/block/blockjob.h b/include/block/blockjob.h
index 2290bbb824..ede0bd8dcb 100644
--- a/include/block/blockjob.h
+++ b/include/block/blockjob.h
@@ -122,16 +122,6 @@ int block_job_add_bdrv(BlockJob *job, const char *name, BlockDriverState *bs,
void block_job_remove_all_bdrv(BlockJob *job);
/**
- * block_job_wakeup_all_bdrv:
- * @job: The block job
- *
- * Calls bdrv_wakeup() for all BlockDriverStates that have been added to the
- * job. This function is to be called whenever child_job_drained_poll() would
- * go from true to false to notify waiting drain requests.
- */
-void block_job_wakeup_all_bdrv(BlockJob *job);
-
-/**
* block_job_set_speed:
* @job: The job to set the speed for.
* @speed: The new value