Lines Matching +full:wait +full:- +full:on +full:- +full:read

22 #include "qemu/main-loop.h"
23 #include "block/graph-lock.h"
33 /* Written and read with atomic operations. */
37 * Many write-locked sections are also drained sections. There is a convenience
41 * because the aio_poll() call in bdrv_graph_wrlock() might re-enter
43 * bdrv_graph_wrunlock() might also re-enter a write-locked section.
66 * List of BdrvGraphRWlock kept in graph-lock.c
88 ctx->bdrv_graph = g_new0(BdrvGraphRWlock, 1); in register_aiocontext()
90 assert(ctx->bdrv_graph->reader_count == 0); in register_aiocontext()
91 QTAILQ_INSERT_TAIL(&aio_context_list, ctx->bdrv_graph, next_aio); in register_aiocontext()
97 orphaned_reader_count += ctx->bdrv_graph->reader_count; in unregister_aiocontext()
98 QTAILQ_REMOVE(&aio_context_list, ctx->bdrv_graph, next_aio); in unregister_aiocontext()
99 g_free(ctx->bdrv_graph); in unregister_aiocontext()
112 rd += qatomic_read(&brdv_graph->reader_count); in reader_count()
136 * reader_count == 0: this means writer will read has_reader as 1 in bdrv_graph_wrlock()
137 * reader_count >= 1: we don't know if writer read has_writer == 0 or 1, in bdrv_graph_wrlock()
138 * but we need to wait. in bdrv_graph_wrlock()
139 * Wait by allowing other coroutine (and possible readers) to continue. in bdrv_graph_wrlock()
185 /* Wake up all coroutines that are waiting to read the graph */ in bdrv_graph_wrunlock()
195 * BHs don't deadlock if their condition relies on the coroutine making in bdrv_graph_wrunlock()
202 wrlock_quiesced_counter--; in bdrv_graph_wrunlock()
210 bdrv_graph = qemu_get_current_aio_context()->bdrv_graph; in bdrv_graph_co_rdlock()
213 qatomic_set(&bdrv_graph->reader_count, in bdrv_graph_co_rdlock()
214 bdrv_graph->reader_count + 1); in bdrv_graph_co_rdlock()
219 * has_writer == 0: this means writer will read reader_count as >= 1 in bdrv_graph_co_rdlock()
220 * has_writer == 1: we don't know if writer read reader_count == 0 in bdrv_graph_co_rdlock()
221 * or > 0, but we need to wait anyways because in bdrv_graph_co_rdlock()
233 * Then the writer will read reader_count that does not take into in bdrv_graph_co_rdlock()
238 * then writer will read reader_count >= 1. in bdrv_graph_co_rdlock()
239 * It will wait in AIO_WAIT_WHILE(), but once it releases the lock in bdrv_graph_co_rdlock()
263 bdrv_graph->reader_count--; in bdrv_graph_co_rdlock()
273 bdrv_graph = qemu_get_current_aio_context()->bdrv_graph; in bdrv_graph_co_rdunlock()
275 qatomic_store_release(&bdrv_graph->reader_count, in bdrv_graph_co_rdunlock()
276 bdrv_graph->reader_count - 1); in bdrv_graph_co_rdunlock()
281 * has_writer == 0: this means reader will read reader_count decreased in bdrv_graph_co_rdunlock()
282 * has_writer == 1: we don't know if writer read reader_count old or in bdrv_graph_co_rdunlock()
283 * new. Therefore, kick again so on next iteration in bdrv_graph_co_rdunlock()
284 * writer will for sure read the updated value. in bdrv_graph_co_rdunlock()