block: Add @drained_end_counter
commit8e1da77e6e4866876236d0f0c7b02dea87efd2a4
authorMax Reitz <mreitz@redhat.com>
Fri, 19 Jul 2019 09:26:11 +0000 (19 11:26 +0200)
committerKevin Wolf <kwolf@redhat.com>
Fri, 19 Jul 2019 11:19:16 +0000 (19 13:19 +0200)
treefb8b31c7f5551bd6c9eff749679efe99822b7e90
parent8e4428106aecb05a55c8cc97d927adaab7454b71
block: Add @drained_end_counter

Callers can now pass a pointer to an integer that bdrv_drain_invoke()
(and its recursive callees) will increment for every
bdrv_drain_invoke_entry() operation they schedule.
bdrv_drain_invoke_entry() in turn will decrement it once it has invoked
BlockDriver.bdrv_co_drain_end().

We use atomic operations to access the pointee, because the
bdrv_do_drained_end() caller may wish to end drained sections for
multiple nodes in different AioContexts (bdrv_drain_all_end() does, for
example).

This is the first step to moving the polling for BdrvCoDrainData.done to
become true out of bdrv_drain_invoke() and into the root drained_end
function.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block/io.c